繁体   English   中英

显示特定类别的帖子-Wordpress

[英]Show posts from a specific category - Wordpress

我遇到一个问题,即我只需要显示某个类别的房屋中的特定帖子,否则它会显示所发布的所有内容,并且我将网站周围的帖子用于其他目的。

<?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页面以获取更多详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM