Php 如何通过选项卡在首页显示特定类别的帖子

Php 如何通过选项卡在首页显示特定类别的帖子,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

我在首页的开头插入了一些引导导航选项卡,这些选项卡中的任何一个都用于特定类别的帖子。
我如何单击其中一个选项卡以及我想要的某个类别的帖子(显示在该选项卡上)。

您必须添加循环过滤器,并通过每个选项卡上的特定类别进行查询。很像

<?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文档,请看“组合参数”

这里是否已回答了allready的问题: