我遇到了一个问题,我需要从某个类别中只显示我家中的特定帖子,否则它会显示任何内容和发布的所有内容,我正在使用网站周围的帖子用于其他目的。
<?php query_posts('posts_per_page=3'); while(have_posts()) : the_post(); ?>
<span style="float: left; width: 180px; height: 180px; padding: 0px 60px 0px 0px;"><?php the_post_thumbnail( array(220,200) ); ?> </span>
<h3 class="excerptHeader" style="margin-top: 0px;"><a class="excerptHeader" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<span class="excerpt"><p><?php echo substr(get_the_excerpt(), 0,80); ?> [...]</p></span>
<span class="excerpt"><p><a class="excerptLink" href="<?php the_permalink(); ?>">Read full article</a></p></span>
<?php endwhile; wp_reset_query(); ?>
我试过添加:
按如下方式更改查询参数:
query_posts('posts_per_page=3&cat=nn')
其中nn
为您希望从中选择帖子的类别的ID
。
查看query_posts页面了解更多详细信息