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

筅森魡賤 提交于 2019-12-01 00:01:51

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.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!