How to exclude categories from Category widget in functions.php

Add the following function in functions.php of your active (child?) theme and adjust the category ID numbers:

// Hide categories from WordPress category widget
function mo_exclude_widget_categories($args){
 $exclude = "1,3,4"; // add category IDs here
 $args["exclude"] = $exclude;
 return $args;
}
add_filter("widget_categories_args","mo_exclude_widget_categories");

 

Leave a Reply