Exclude categories from the default widget “Categories”

When building a WordPress site, there are a lot of different bits and bobs to put in place before the theme, and your site, is up and running. Of course, one of the most important parts of your site are your widgets, as they help to provide useful links and sections down your sidebars for any new visitors. Of course, one of the most common, especially if you’re a site with blog or journalistic content, is going to be your categories list.

So, say you’ve got some categories you use privately so you know which posts you used to talk about your IMAP email server, and which ones you used to talk about the times you play Foxy bingo (www.foxybingo.com). If you don’t want these categories to show up, but you do want “everyday”, “going out”, “thoughts on politics” and such to show without costing you the entire widget, there is a solution. Read on to learn how to sort this issue.

To exclude categories from WordPress default widget “Categories”, add this code in the file functions.php of the using theme:

function exclude_widget_categories($args){
  $exclude = "3,6,18"; // The IDs of the excluding categories
  $args["exclude"] = $exclude;
  return $args;

The method to exclude the categories from the widget is better, as it is in the file of the theme and it will work after the updating WordPress versions.

After the widget, time to deal with your hosting. Learn more about best wordpress host providers at WebHostingSearch.com.

  • Share/Bookmark
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

5 Responses to “Exclude categories from the default widget “Categories””

  1. Anders says:

    I have just got a blog and use about 50 different plugins. Thank you very much for your plugin. It complete my website

  2. Patryk says:

    This is it!! Thanks

  3. Hendrik says:

    Holy shit! Thanks a bunch! I was looking exactly for something like this and even started to edit core files and your solution just does it…

    Thanks again!

  4. Muhammed says:

    Pure awesomeness. thanks a mil

  5. sierra says:

    Wow this does it! Hiding categories was making that category’s RSS feed path show up as “Page not found” until I found your solution. Thanks a lot!

Leave a Reply