I am trying to load my custom post type events into jquery plugin full calendar but nothing is working. I have made a php file with this code
include "wp-load.php";
global $wpdb;
header('Content-Type:application/json');
$events = array();
$result = new WP_Query('post_type=events&posts_per_page=-1');
foreach($result->posts as $post) {
$events[] = array(
'title' => $post->post_title,
'start' => '2018-03-12T20:00:00',
);
}
echo json_encode($events);
exit;
But its not loading anything
include
statement by arequire
, so that the script breaks if it cannot find the filewp-load.php
And finally, you could add these two lines after therequire
:ini_set('display_errors', 1);
andini_set('error_reporting', E_ALL);
.