问题描述
如何在我的 wordpress 索引页面中只显示特定类别?下面是我的主题代码...
此外,在查看我的类别的 URL 时(我通常如何获取 ID),它似乎是一种奇怪的格式..
<? 'event-news' ) );?><?
<li id="post-<? 'loop-main', 'width' => 160, 'height' => 120, 'before' => '
' ) );?><div class="postcontent"><h2><a href="<?"发布日期><?</div><!-- end .postmetadata --><?<p class="more"><a href="<?--><?<div class="cleaner"> </div><?<?</div><!-- end .box -->
你可以在循环之前做 query_post
query_posts( array ( 'category_name' => 'my-category-slug' ) );
如果您想要来自多个类别的帖子,那么您可以使用
query_posts('cat=8,4,3');
8,4,3 是 3 个类别的 id
在循环之后使用
wp_reset_query();
有关更多详细信息,请查看此链接
http://codex.wordpress.org/Function_Reference/query_posts#All_Posts_in_a_Category
How Can I only show a specific category in my wordpress index page? Below is my theme code...
Also, when looking at the URL for my category (how I usually get the ID) it seems a strange format..
You can do query_post just before the loop If you want posts from more than one category then you can use 8,4,3 are the id for the 3 categories and after the loop use For more details view this link http://codex.wordpress.org/Function_Reference/query_posts#All_Posts_in_a_Category 这篇关于只在 wordpress 循环中显示特定类别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!<?
<li id="post-<?
query_posts( array ( 'category_name' => 'my-category-slug' ) );
query_posts('cat=8,4,3');
wp_reset_query();