我在Wordpress的第一天,一切都不顺利。。。我只是有一个简单的循环,我希望在其中显示特定类别的一些帖子。这是我的代码:
<?php
$args = array(
\'numberposts\' => 5,
\'category\' => 2,
\'offset\' => 0,
\'order\' => \'date\',
\'post_type\' => \'post\',
\'post_status\' => \'publish\'
);
$foodPosts = get_posts($args);
foreach ($foodPosts as $foodPost) : setup_postdata($foodPost);
?>
<div><?php the_permalink(); ?></div>
<div><?php the_title(); ?></div>
<div><?php the_content(); ?></div>
<?php endforeach; wp_reset_postdata(); ?>
这是输出:http://10.0.1.174/mysite/?p=7
Cool post title
this is yet another food post
http://10.0.1.174/mysite/?p=7
Cool post title
this post is in the food category
http://10.0.1.174/mysite/?p=7
Cool post title
this is a post about food
因此,每个帖子的内容都是正确的,但由于某种原因,所有的永久链接和标题都与第一篇帖子相同。怎么了?