仅显示所选类别的帖子

时间:2011-03-28 19:12:41

标签: php wordpress

如何仅显示(通过修改主题)某个类别的帖子而不是全部显示?

3 个答案:

答案 0 :(得分:1)

这应该有效

<?php query_posts('cat=1'); ?>
<?php while (have_posts()) : the_post(); ?>
  <!-- post's contents -->
<?php endwhile; ?>

答案 1 :(得分:1)

您寻求的答案在于Wordpress文档。如果您查找的时间超过2秒,那就在那里:http://codex.wordpress.org/The_Loop#Loop_Examples

答案 2 :(得分:0)

最简单的形式:

$query = new WP_Query( 'category_name=foo' );