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:

<?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");
?>

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.

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

One Response 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

Leave a Reply