【发布时间】:2016-03-16 06:21:00
【问题描述】:
我正在尝试在我的 PHP 网站中显示来自另一个使用已安装 WP REST API 插件的 Wordpress 网站的一些帖子。我正在尝试使用下面的代码执行此操作,但没有任何反应:
<?php
$json = file_get_contents('http://noticias.uscs.edu.br/wp-json/wp/v2/posts?filter[posts_per_page]=6&filter[orderby]=date');
// 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 ? '<img src="' . $p->featured_image->guid . '">' : '';
}
?>
有什么意见吗?提前致谢。
【问题讨论】: