如何通过标签在首页显示特定类别的帖子

how to display posts of a particular category in front page via tabs

我在首页的头部插入了一些 bootstrap 导航选项卡,这些选项卡中的任何一个都用于指定的帖子类别。 我怎样才能点击其中一个选项卡和我想要的特定类别的帖子,显示在该选项卡上。

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

<?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看看"Combining Parameters"

已经在这里回答了:Only show specific category in wordpress loop?