The following code will help you remove a category from being displayed in your WordPress website.
/** Remove the private projects everywhere */
function globally_exclude_category( $wp_query ) {
// Add the category to an array of excluded categories. In this case, though,
// it's really just one.
$excluded = array( '-84' );
// Note that this is a cleaner way to write:
$wp_query->set('category__not_in', $excluded);
set_query_var( 'category__not_in', $excluded );
}
add_action( 'pre_get_posts', 'globally_exclude_category' );
function globally_exclude_category_widget($args){
$exclude = "84";
// The IDs of the excluding categories, comma separated
$args["exclude"] = $exclude;
return $args;
}
add_filter("widget_categories_args", "globally_exclude_category_widget");
Code language: PHP (php)