0

I need to hide the Uncategorized category from the default sidebar.

I edited the file wp-includes/widgets/class-wp-widget-categories.php, but I did not see any changes. Here is an image of my sidebar, where the blog is listed under the "Uncategorized" category, which I want to hide.

enter image description here

how can i achieve this?

2
  • That's not the default WordPress sidebar. It's a widget or block added by a theme or plugin. Jul 25 at 11:41
  • How I can found this code
    – waqas023
    Jul 25 at 14:14

1 Answer 1

0

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.

4
  • It is not hiding even I cleared my Cache
    – waqas023
    Jul 25 at 6:48
  • Looks like the widget you're trying to edit isn't core's category widget. Jul 25 at 10:23
  • I don't know but I found this sidebar In apparence section of WordPress and here they said default sidebar.
    – waqas023
    Jul 25 at 14:13
  • What theme are you using? Can you try switching to a different theme like core's defaults themes and see if that widget exists after you change theme? If it's not there, that means it's a widget added by a theme/plugin. Jul 27 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.