Excluding Specifice Category From Widget

WordPress have many plugins for that but we can do this with php code too.

For Exclude or hide a category from WP widget you should be place given code in our WP theme function.php file.

1
2
3
4
5
6
7
8
<?php
function exclude_widget_categories($args){
$exclude = "3,6,18"; // The IDs of the excluding categories
$args["exclude"] = $exclude;
return $args;
}
add_filter("widget_categories_args","exclude_widget_categories");
?>

Leave a Reply