Home › Forums › Calendar Products › Events Calendar PRO › How do I load my custom single-event with Ajax
- This topic has 2 replies, 2 voices, and was last updated 9 years, 9 months ago by Barry.
-
AuthorPosts
-
May 23, 2014 at 7:30 am #171953livogParticipant
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->ID;
get_template_part('tribe-events/single-event.php');
}
}function tribe_get_event_by_slug($event_id, $output = OBJECT) {
global $wpdb;
$post = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type='tribe_events'", $event_id ));
if ( $post ) {
return get_post($post, $output);
}
}
It only give me alot of errors when I click on the event.Here is the Javascript if anyone wanna use that to.
$(document).on('click','.tribe-mini-calendar-event a', function(e){
e.preventDefault();var url = $(this).attr('href');
$.ajax({
data: {
url: url
},
url: "/enterprise/wp-content/themes/igomoon-apollo/testajax.php",
type: "GET",
success: function( data ) {
$('.content').html(data);
console.log(data);
}});
return false;});
Any help is appreciate!May 26, 2014 at 8:00 am #177620BarryMemberHi!
I’m afraid we can’t help a great deal with custom development questions like this one – but can you give me a better sense of what errors you are seeing?
One thing I do notice, unless I’m missing something/it’s catered for in your custom single-event.php template, is that you don’t appear to be setting up the global $post object – if so, any number of functions within the template may fail as they will not “know” which event is being referred to.
July 25, 2014 at 7:10 am #506017BarryMemberHi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!
-
AuthorPosts
- The topic ‘How do I load my custom single-event with Ajax’ is closed to new replies.