【问题标题】:how to display posts of a particular category in front page via tabs如何通过标签在首页显示特定类别的帖子
【发布时间】:2016-02-11 09:07:37
【问题描述】:

我在首页的顶部插入了一些引导导航选项卡,这些选项卡中的任何一个都用于指定类别的帖子。 我如何点击其中一个选项卡和我想要的某个类别的帖子,显示在该选项卡上。

【问题讨论】:

    标签: php wordpress post tabs categories


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多