How to Hide Uncategorized Category from WooCommerce website

The uncategorized category is one of the most annoying things of WooCommerce and no one wants to show this category to its visitors. It looks ugly and unprofessional and it is completely useless for visitors because no one wanna find anything in the uncategorized category.

The problem with this category it is a must-have for WooCommerece you can’t delete it. But in today’s article, we are going to learn how we can remove this category. We will not be going to remove this cause it will break the website instead we will hide this.

We have three options to hide this Uncategorized category from our website. And below we have shared all three options with you.

1. Keep it clean

The first and recommended thing is to not keeping anything in the uncategorized category. To hide this category from the user just don’t keep anything in this category it won’t show up in your shop. It is also very good practice to properly categorize your products so the users can easily find them. You can follow this tutorial where we have explained how you should properly list your product in WooCommerce.

2. Rename it

Another option to hide this category is to rename it in something meaningful so even if it shows up on the shop page it will look meaningful.

Steps to rename

  1. Go to your WordPress admin page and navigate to Products>Categories.
  2. Now select the uncategorized category and click on Edit.
  3. Now rename the category title and slug to whatever you want.

3. Insert code

This is one of the less recommended options especially for new users cause it may break your website if you did something wrong. Now let’s know how you can do that.

Steps to insert code

  1. To insert code onto your website go to your admin panel and navigate to Appearance>Theme Editor.
  2. Now open your function.php file and paste the code which is given below.

/**
 * Exclude products f<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>rom a uncategorized category on the shop page
 */
function custom_pre_get_posts_query( $q ) {

    $tax_query = (array) $q->get( 'tax_query' );

    $tax_query[] = array(
           'taxonomy' => 'product_cat',
           'field' => 'slug',
           'terms' => array( 'uncategorized' ), // Don't display products in the clothing category on the shop page.
           'operator' => 'NOT IN'
    );


    $q->set( 'tax_query', $tax_query );

}
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' ); 

This code is from official WooCommerce documentation you can go to this link to check details.

It is recommended to instead of making changes to your parent theme you should make changes to your child theme. You can follow our child theme guide to make a child theme on your WordPress website.

Conclusion

Now you know all the possible ways to hide the annoying uncategorized category from your WooCommerce website. Try any above option whichever suites your need and if you face any issue while doing it let me know in the comment below.

Have questions or confused about something WordPress Related? Join Our Discord Server & ask a Question

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top