While using WordPress, you may need to exclude or hide certain categories from the categories widget.

There are some plugins available to achieve this, but inserting suitable code is advisable.

Here is the code:

function exclude_widget_categories($args){
$exclude = “1,15,22”; // The IDs of the excluding categories
$args[“exclude”] = $exclude;
return $args;
}
add_filter(“widget_categories_args”,”exclude_widget_categories”);

 

Insert this code before ?> in theme function.php file.

(Note: The category numbers 1,15,22 is just for illustration. You need to replace with yours.)