How to Exclude Category from Sidebar Widgets – WordPress

Advertisement

Have you work with WordPress Category widget? And found out that you can’t exclude other category from display? Excluding other category is useful if you don’t want the users or site viewers to see the specific or list of category. Today I will share you a very simple solution how you can easily exclude categories from sidebar widget.

Solution

Copy and paste this snippet into your functions.php of your current theme, if you don’t have one please create and paste this snippet.


<?php
function ryans_exclude_categories($args){
   $exclude = "3,6,18"; // The list or number of category ID's you want to exclude.
   $args["exclude"] = $exclude;
   return $args;
}

add_filter("widget_categories_args"," ryans_exclude_categories");
?>

Don’t want to get your hand dirty?

As always I will provide plugin it there’s any :), visit http://justintadlock.com/archives/2008/12/09/widgets-reloaded-wordpress-plugin to download the plugin and see lots of built-in functionalities.

That’s it, if you have some suggestions or solutions please share it by commenting below.

Advertisement