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!