Wordpress - Exclude a category from appearing in menu or sidebar widgets

前端 未结 2 1983
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 01:36

Is there a simple solution (e.g a plugin) for excluding categories appearing in a menu or sidebar? I created a category of posts called \"videos\" which display youtube vid

相关标签:
2条回答
  • 2021-01-07 02:07

    I found this code in WordPress forum which seems to do exactly what you need:

    <?php
      function exclude_widget_categories($args)
      {
        $exclude = "3,6,18"; // The IDs of the excluding categories
        $args["exclude"] = $exclude;
        return $args;
      }
      add_filter("widget_categories_args","exclude_widget_categories");
    ?> 
    

    Put the code in functions.php of your theme.

    0 讨论(0)
  • 2021-01-07 02:34

    You can use a simple plugin widget instead where you can specify certain categories

    http://wordpress.org/extend/plugins/custom-recent-posts-widget

    0 讨论(0)
提交回复
热议问题