WordPress: Exclude default categories from the default ‘Categories’ widget

 Posted on 18 March 2012

wordpress plugins interface navigation WordPress: Exclude default categories from the default Categories widgetThanks to a message posted a Web User Forums I found a wordpress hook that caught my attention, as it serves to hide categories from the widget that WordPress displays by default, to display the list of categories on the sidebar.

To exclude one or more of the default categories from the “Categories” widget of WordPress, add these lines of code in the functions.php of the theme you are using:

exclude_widget_categories function ($ args) {
$ exclude = "3,6,18" / / The IDs of categories to exclude
$ args ["exclude"] = $ exclude;
return $ args;
}
add_filter ("widget_categories_args" "exclude_widget_categories");

If your theme does not contain any file functions.php, you can create one yourself remembering that you must edit this as plain text. In that case you should also set the php tag:

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

I hope this is as useful to you as it was for me icon wink WordPress: Exclude default categories from the default Categories widget

Share with your friends!
Published by dennis in WordPress

1 comment

  1. iTechGiz says:

    These helpful works by WordPress makes it The World Press. By the way thanks.

Write a comment

YES you can use HTML code in comments.
NO you cannot leave spam or insult anyone.

Your coment will be moderated the first time. Later on it will not be moderated as long as you use the same contact info.