I want to get the posts from post type = events but it is not showing the correct posts from events post type but from the actual WP-POST
<?php
// Get the JSON
$json = file_get_contents('http://coralgableschamber.org/wp-json/posts?filter[posts_per_page]=1&filter[post_type]=events');
// Convert the JSON to an array of posts
$posts = json_decode($json);
foreach ($posts as $p) {
echo '<p>Title: ' . $p->title . '</p>';
echo '<p>Date: ' . date('F jS', strtotime($p->date)) . '</p>';
// Output the featured image (if there is one)
echo $p->featured_image ? '<amp-img src="' . $p->featured_image->guid . '" width="150" height="110"></amp-img>' : '';
echo '<p>Content: ' . $p->content. '</p>';
}
The event post type have the following posts in it but it is not showing these
It is showing wrong post check this link: http://mxcounters.com/coralgables/AMP/front.html
What is wrong and how i can fix to make it work.
Thanks!
Try using http://coralgableschamber.org/wp-json/posts?type=events instead.
You can look at http://coralgableschamber.org/wp-json/ to see all available paths.