0

我想从 post type = events 获取帖子,但它没有显示来自 events 帖子类型的正确帖子,而是来自实际的 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>';    

   }

事件帖子类型中包含以下帖子,但未显示这些帖子 在此处输入图像描述

它显示错误的帖子检查此链接: http: //mxcounters.com/coralgables/AMP/front.html

出了什么问题以及如何解决以使其正常工作。

谢谢!

4

1 回答 1

1

尝试改用http://coralgableschamber.org/wp-json/posts?type=events

您可以查看http://coralgableschamber.org/wp-json/以查看所有可用路径。

于 2016-12-02T17:24:23.297 回答