{"id":171953,"date":"2014-05-23T07:30:54","date_gmt":"2014-05-23T14:30:54","guid":{"rendered":"http:\/\/tri.be\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/"},"modified":"2014-07-25T07:12:15","modified_gmt":"2014-07-25T14:12:15","slug":"how-do-i-load-my-custom-single-event-with-ajax","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/","title":{"rendered":"How do I load my custom single-event with Ajax"},"content":{"rendered":"<p>I am trying to load the single-event.php when I click on a event in the Mini calendar widget.<\/p>\n<p>Here is what happen in my ajax callback function:<\/p>\n<p><code><br \/>\nrequire_once('..\/..\/..\/wp-load.php');<\/p>\n<p>if(isset($_GET['url'])) {<br \/>\n\tif(!empty($_GET['url'])) {<br \/>\n\t\t$url = $_GET['url'];<br \/>\n\t\t$url = explode('\/', $url);<\/p>\n<p>\t\t$arraycount = count($url);<br \/>\n\t\t$event_slug = $url[$arraycount - 2];<br \/>\n\t\t$event_array = tribe_get_event_by_slug($event_slug);<\/p>\n<p>\t\t$event_id = $event_array-&gt;ID;<\/p>\n<p>\t\tget_template_part('tribe-events\/single-event.php');<\/p>\n<p>\t}<br \/>\n}<\/p>\n<p>function tribe_get_event_by_slug($event_id, $output = OBJECT) {<br \/>\n    global $wpdb;<br \/>\n    $post = $wpdb-&gt;get_var( $wpdb-&gt;prepare( \"SELECT ID FROM $wpdb-&gt;posts WHERE post_name = %s AND post_type='tribe_events'\", $event_id ));<br \/>\n    if ( $post ) {<br \/>\n        return get_post($post, $output);<br \/>\n    }<br \/>\n}<br \/>\n<\/code><br \/>\nIt only give me alot of errors when I click on the event.<\/p>\n<p>Here is the Javascript if anyone wanna use that to.<br \/>\n<code><br \/>\n$(document).on('click','.tribe-mini-calendar-event a', function(e){<br \/>\n\t\te.preventDefault();<\/p>\n<p>\t\tvar url = $(this).attr('href');<br \/>\n\t\t$.ajax({<br \/>\n\t\t    data: {<br \/>\n\t\t\t    url: url<br \/>\n\t\t    },<br \/>\n\t\t    url: \"\/enterprise\/wp-content\/themes\/igomoon-apollo\/testajax.php\",<br \/>\n\t\t    type: \"GET\",<br \/>\n\t\t    success: function( data ) {<br \/>\n\t\t        $('.content').html(data);<br \/>\n\t\t        console.log(data);<br \/>\n\t\t    }<\/p>\n<p>\t\t});<br \/>\n\t\treturn false;<\/p>\n<p>\t});<br \/>\n<\/code><br \/>\nAny help is appreciate!<\/p>\n","protected":false},"template":"","class_list":["post-171953","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How do I load my custom single-event with Ajax -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How do I load my custom single-event with Ajax -\" \/>\n<meta property=\"og:description\" content=\"I am trying to load the single-event.php when I click on a event in the Mini calendar widget. Here is what happen in my ajax callback function: require_once(&#039;..\/..\/..\/wp-load.php&#039;); if(isset($_GET[&#039;url&#039;])) { if(!empty($_GET[&#039;url&#039;])) { $url = $_GET[&#039;url&#039;]; $url = explode(&#039;\/&#039;, $url); $arraycount = count($url); $event_slug = $url[$arraycount - 2]; $event_array = tribe_get_event_by_slug($event_slug); $event_id = $event_array-&gt;ID; get_template_part(&#039;tribe-events\/single-event.php&#039;); } [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/\" \/>\n<meta property=\"article:modified_time\" content=\"2014-07-25T14:12:15+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/\",\"name\":\"How do I load my custom single-event with Ajax -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2014-05-23T14:30:54+00:00\",\"dateModified\":\"2014-07-25T14:12:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How do I load my custom single-event with Ajax\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How do I load my custom single-event with Ajax -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/","og_locale":"en_US","og_type":"article","og_title":"How do I load my custom single-event with Ajax -","og_description":"I am trying to load the single-event.php when I click on a event in the Mini calendar widget. Here is what happen in my ajax callback function: require_once('..\/..\/..\/wp-load.php'); if(isset($_GET['url'])) { if(!empty($_GET['url'])) { $url = $_GET['url']; $url = explode('\/', $url); $arraycount = count($url); $event_slug = $url[$arraycount - 2]; $event_array = tribe_get_event_by_slug($event_slug); $event_id = $event_array-&gt;ID; get_template_part('tribe-events\/single-event.php'); } [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/","article_modified_time":"2014-07-25T14:12:15+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/","name":"How do I load my custom single-event with Ajax -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2014-05-23T14:30:54+00:00","dateModified":"2014-07-25T14:12:15+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-do-i-load-my-custom-single-event-with-ajax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"How do I load my custom single-event with Ajax"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/171953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/171953\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=171953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}