【发布时间】:2016-02-11 09:07:37
【问题描述】:
我在首页的顶部插入了一些引导导航选项卡,这些选项卡中的任何一个都用于指定类别的帖子。 我如何点击其中一个选项卡和我想要的某个类别的帖子,显示在该选项卡上。
【问题讨论】:
标签: php wordpress post tabs categories
我在首页的顶部插入了一些引导导航选项卡,这些选项卡中的任何一个都用于指定类别的帖子。 我如何点击其中一个选项卡和我想要的某个类别的帖子,显示在该选项卡上。
【问题讨论】:
标签: php wordpress post tabs categories
您必须添加您的循环过滤器并在每个选项卡上专门通过类别进行查询。很喜欢
<?php global $query_string; // required
$posts = query_posts($query_string.'&cat=12'); // only show posts from category with the ID 12 ?>
<?php // YOUR USUAL LOOP HERE ?>
<?php wp_reset_query(); // reset the query ?>
您也可以排除类别
<?php global $query_string; // required
$posts = query_posts($query_string.'&cat=-12'); // Show al posts that are NOT in category with ID 12 ?>
<?php // YOUR USUAL LOOP HERE ?>
<?php wp_reset_query(); // reset the query ?>
这里是wordpress文档http://codex.wordpress.org/Template_Tags/query_posts看看“组合参数”
【讨论】: