0

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

1
  • This is not the correct way to load WordPress. You should move that code to a plugin, or a child theme. Also, I would replace the include statement by a require, so that the script breaks if it cannot find the file wp-load.php And finally, you could add these two lines after the require: ini_set('display_errors', 1); and ini_set('error_reporting', E_ALL);.
    – Mike
    May 27, 2018 at 14:50

1 Answer 1

0

Have reviewed your code but could not get what actually is wrong with the code.

Another possible solution is that, you can use third-party WordPress plugin WP Full Calendar and select your post type in the plugin settings. You can then use short-code to display the full calendar in any of your website page/post.

WP FullCalendar: https://wordpress.org/plugins/wp-fullcalendar/

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.