In WordPress, if you want to remove a specific Post Category from the “Categories” widget you will first need to identify the ID of the specific category you wish to hide. You can locate the ID within the WordPress dashboard then by going to Posts > Categories. Hover your mouse over the Category in question then look in the bottom toolbar of your browser and you’ll see a URL string which will show the ID # of said Category. Once you have the Post Category ID (Note: In this example the ID is 1120, you’ll want to replace the number in the code below with the specific ID that applies to you) then you can add the following to your functions.php file:
/* Removes a specific Post Category from Category Widget */
function remove_widget_categories($args)
{
$exclude = “1120”;
$args[“exclude”] = $exclude;
return $args;
}
add_filter(“widget_categories_args”,”remove_widget_categories”);
If you want to hide a specific Post Category from the “Recent Posts” widget in WordPress, use the same method above in regards to finding the Post Category ID # then you can add the following to your functions.php file:
/* Removes Post Category from Recent Posts Widget */
add_filter(‘widget_posts_args’,’modify_widget’);
function modify_widget() {
$r = array( ‘category__not_in’ => ‘1120’);
return $r;
}
If you want to hide more than one Post Category from the “Recent Posts” widget in WordPress, identify the ID #s, then you can add the following to your functions.php file:
/* Remove Multiple Post Categories from Recent Posts Widget */
add_filter(‘widget_posts_args’,’modify_widget’);
function modify_widget() {
$r = array( ‘category__not_in’ => array(3, 4));
return $r;
}