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.
Table of Contents
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
- Go to your WordPress admin page and navigate to Products>Categories.
- Now select the uncategorized category and click on Edit.
- 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
- To insert code onto your website go to your admin panel and navigate to Appearance>Theme Editor.
- Now open your function.php file and paste the code which is given below.
[codeview] /** * 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' ); [/codeview]
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.