【发布时间】:2014-06-16 18:36:02
【问题描述】:
我正在尝试从 wordpress 获取 5 个特色帖子,为了实现这个目标,我已经抵消了 5 个最近的帖子。我成功地获取了帖子 ID、图像。但我没能得到每个帖子的描述。我尝试了下面的代码,但它只给了我 1 个帖子描述,而不是全部 5 个。
$my_posts = get_posts(array('numberposts' => 5,
'offset' => 5,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish'));
foreach($my_posts as $post) {
$data[] =
array(
"id" => $post->ID,
"title" => $post->post_title,
"image" => get_the_post_thumbnail($post->ID),
// "content" =>$post['post_excerpt']
"content" => apply_filters('the_content', $post->post_content)
);
}
【问题讨论】: