Editing the core WordPress files (like class-wp-widget-categories.php
) directly is a no-go. When WordPress updates, it'll overwrite any changes you made to the core files. Plus, it's generally frowned upon in the developer community—it's just not a good habit to get into.
If the widget you're using is the core's default category widget, try adding the following code to your theme's functions.php file:
function exclude_categories($args){
$exclude = get_cat_ID('Blog'); // Get the ID of the category you want to exclude
$args["exclude"] = $exclude; // Exclude the category
return $args;
}
add_filter("widget_categories_args","exclude_categories");
After adding this, the "Blog" category should disappear from the sidebar. If it's still playing coy, clear your cache, then take another look.