For an e-commerce site, the most important page is the shop page where most of the business is done, and where customers can see the products for sale.
So the shop page has to be flawless; from presentation to functionality. By default, all the products from all categories will be shown which is fine for some, but not desirable for others.
You might only want to show a specific category on your shop page, but don’t know how. The following instructions created by our team at wpDataTables will show you how to hide a WooCommerce category from your shop page.
Hide the WooCommerce Category from the Shop Page
There are two different methods:
Method #1: Hiding the Category Using the get_terms Filter
It’s undesirable to show all the categories on your shop page, and so you’ll want to hide some, especially if you don’t want the generic, “uncategorized” category to show up, which makes your site more confusing and somewhat unappealing.
It can be hidden from the shop page easily, or you can rename the category and make it more relevant. You can hide it with this method.
- First, you’ll need to find a slug for the category. Go to Products > Categories from the WordPress dashboard.
- The slug for the Uncategorized category is “uncategorized”. If you want to make this category hidden from your child theme, enter the following code into functions.php.
add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 ); function ts_get_subcategory_terms( $terms, $taxonomies, $args ) { $new_terms = array(); // if it is a product category and on the shop page if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) { foreach( $terms as $key => $term ) { if ( !in_array( $term->slug, array( 'uncategorised' ) ) ) { //pass the slug name here $new_terms[] = $term; }} $terms = $new_terms; } return $terms; }
- the get_terms function has been added to the category. The category “Uncategorized” should not be visible anymore.
- You can then enter the slug names for all the categories you want to hide:
add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 ); function ts_get_subcategory_terms( $terms, $taxonomies, $args ) { $new_terms = array(); // if it is a product category and on the shop page if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) { foreach( $terms as $key => $term ) { if ( !in_array( $term->slug, array( 'uncategorised','furniture' ) ) ) { //pass the slug name here $new_terms[] = $term; }} $terms = $new_terms; } return $terms; }
This specific code will hide the items from the category “Uncategorized” and “furniture”.
Method #2: Using the “woocommerce_product_query_tax_query” filter
The second method for hiding uncategorized products from the shop page is by using the action called woocommerce_product_query. You’ll need to add this with the functions.php file. Add the code this way:
add_action( 'woocommerce_product_query', 'prefix_custom_pre_get_posts_query' ); /** * Hide Product Categories from targeted pages in WooCommerce * @link https://gist.github.com/stuartduff/bd149e81d80291a16d4d3968e68eb9f8#file-wc-exclude-product-category-from-shop-page-php * */ function prefix_custom_pre_get_posts_query( $q ) { if( is_shop() || is_page('awards') ) { // set conditions here $tax_query = (array) $q->get( 'tax_query' ); $tax_query[] = array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'operator' => 'NOT IN' ); $q->set( 'tax_query', $tax_query ); } }
This code targets the pages where you don’t want the Product Categories displayed. You’ll need to set the values in the $tax_query array to the values of the categories you want to be removed.
How?
Using the “woocommerce_product_query_tax_query” filter we check whether there is already an “is_shop()” function used on the page. With the query, we can add more taxonomy search criteria to be more specific.
Then, add an array to the taxonomy that will reduce or remove the desired categories on their slugs. In the example above, we removed the T-shirts and hoodies categories. You can specify any values you want.
You can use either of these two methods to hide the WooCommerce category from the shop page.
How to Not Show WooCommerce Categories in Widgets
This script is useful for removing the category from the widget. It filters the woocommerce_product_categories_widget_args hook. Here’s the code:
add_filter( 'woocommerce_product_categories_widget_args', 'organicweb_exclude_widget_category' ); function organicweb_exclude_widget_category( $args ) { // Enter the id of the category you want to exclude in place of '30' $args['exclude'] = array('30' ); return $args; }
How to Hide Categories from Users
You can have a lot more control over who can and can’t see the categories. This is especially useful if you want to hide the categories from users. The WooCommerce hide category from shop page for users function is done like this:
add_filter( 'woocommerce_product_query_tax_query', 'hwn_hide_shop_categories_by_role'); function hwn_hide_shop_categories_by_role($tquery) { $user = wp_get_current_user(); $blocked_user_roles = array("customer","administrator"); $hidden_categories = array("tshirts", "hoodies"); if (is_shop() && (!is_user_logged_in() || is_user_logged_in() && count(array_intersect($blocked_user_roles,$user->roles)) > 0)) { $tquery[] = array( 'taxonomy' => 'product_cat', 'terms' => $hidden_categories, 'field' => 'slug', 'operator' => 'NOT IN' ); } return $tquery; }
Here’s how this code works.
In essence, this snippet of code is similar to the above code. However, this code will obtain the details of the current user with the function wp_get_current_user. Then, you can define the roles that you want the categories to be hidden from. With this code, we have defined that only the categories tshirt and hoodies will be visible for the selected users.
With this code, we’ll hide the categories.
if (is_shop() && (!is_user_logged_in() || is_user_logged_in() && count(array_intersect($blocked_user_roles,$user->roles)) > 0))
This code works in this way: the first part of the if statement checks whether you are on the same page as before, and identifies if the user is still logged in. If they belong to blocked users, they will not be able to see the categories. Remember to use the codes in the functions.php file of your theme.
How to Hide Products from a WooCommerce product category
In this tutorial, we’ll take a look at how to remove products from categories instead of removing categories in the first place.
Perhaps you don’t want to show the products from a specific category that you have deleted before. So now the categories “uncategorized” and “furniture” will not be shown, but how can you prevent the products from these categories from showing as well? The screenshot shows two products from the category Furniture.
You’ll need to add this code snippet to the functions.php file:
add_action( 'woocommerce_product_query', 'ts_custom_pre_get_posts_query' ); function ts_custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( 'tax_query' ); $tax_query[] = array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' =>array( 'uncategorised','furniture'), // Don't display products in the clothing category on the shop page. 'operator' => 'NOT IN' ); $q->set( 'tax_query', $tax_query ); }
So after we enter this code, the products from the Furniture and the Uncategorized categories should not be visible. If you want to remove the categories from showing as well, use the code snippets displayed above.
You can remove the categories as well as the products from the given categories.
FAQs about hiding the category from your WooCommerce shop page
1. How can I hide a specific category from my WooCommerce shop page?
Use the free “WooCommerce Hide Categories” plugin to keep a single category hidden from your WooCommerce shop page. You can select the category you wish to hide by going to the “Product Categories” area of your WordPress dashboard, activating the plugin, and checking the “Hide on Shop page” checkbox.
2. Is it possible to hide multiple categories from my WooCommerce shop page?
Sure, you can use the same “WooCommerce Hide Categories” plugin mentioned above to conceal several categories from your WooCommerce shop page. Simply choose the categories you wish to conceal and mark each one’s “Hide on Shop page” option.
3. Can I hide a category from my WooCommerce shop page without deleting it?
You may remove a category from your WooCommerce shop page without removing it, so the answer is yes. You can easily conceal a category by using the “Hide on Shop page” checkbox using the “WooCommerce Hide Categories” plugin. The category will still be viewable in your WordPress dashboard, and by unchecking the checkbox, you may restore its visibility on the shop page.
4. What happens to products in a hidden category? Can they still be purchased?
Customers with a direct link to the product page can still purchase items in a concealed category. Nevertheless, neither the shop page nor the category listings will show the items.
5. Will the hidden category still be visible in search results or on individual product pages?
A category that is hidden from your WooCommerce shop page will also not appear in search results or on individual product pages. Customers that have access to a hidden product directly can still buy it.
6. How can I show a hidden category again on my WooCommerce shop page?
Simply go to the “Product Categories” area of your WordPress dashboard, choose the category you wish to display, and uncheck the “Hide on Shop page” checkbox to make a hidden category visible once more on your WooCommerce shop page.
7. Can I hide a category from certain user roles or groups in WooCommerce?
It is possible to hide categories from particular user roles or groups with the “WooCommerce Hide Categories” plugin. After editing the category, simply check the boxes next to the user roles or groups you want to conceal the category from.
8. Is there a plugin or extension that can help me hide categories from my WooCommerce shop page?
Sure, there are a number of plugins and extensions like “WooCommerce Hide Categories,” “WooCommerce Category Visibility Options,” and “Conditional Category for WooCommerce” that can let you hide categories from your WooCommerce shop page.
9. How can I hide subcategories from appearing on my WooCommerce shop page?
You can use the same “WooCommerce Hide Categories” plugin stated before to prevent subcategories from showing up on your WooCommerce shop page. Simply select the subcategory you wish to conceal and tick the “Hide on Shop page” checkbox in the “Product Categories” section of your WordPress dashboard.
10. Can I hide a category temporarily and then make it visible again at a specific time?
Sure, you may schedule categories to be hidden and shown at specified times using the “WooCommerce Scheduler” plugin. The plugin will automatically conceal and show the categories in accordance with your selection of the start and finish dates and times and the categories you wish to plan.
Ending thoughts on hiding the WooCommerce category from the shop page
The WooCommerce hide category from the shop page function is important to make your shop page easier to use and manage. It helps to easily organize your products, and you can categorize the products in the right categories.
It’s also great for customers who can choose their desired products, so customer satisfaction will increase, which means an increase in your traffic, sales, and conversions.
Hey, did you know data can be beautiful too?
wpDataTables can make it that way. There’s a good reason why it’s the #1 WordPress plugin for creating responsive tables and charts.

And it’s really easy to do something like this:
- You provide the table data
- Configure and customize it
- Publish it in a post or page
And it’s not just pretty, but also practical. You can make large tables with up to millions of rows, or you can use advanced filters and search, or you can go wild and make it editable.
“Yeah, but I just like Excel too much and there’s nothing like that on websites”. Yeah, there is. You can use conditional formatting like in Excel or Google Sheets.
Did I tell you you can create charts too with your data? And that’s only a small part. There are lots of other features for you.
If you enjoyed reading this article on hiding the WooCommerce category from the shop page, you should check out this one about how to set WooCommerce related products.
We also wrote about a few related subjects like how to change the WooCommerce number of products per page, how to export WooCommerce orders, WooCommerce product variations, WooCommerce appointments plugins, WooCommerce redirect after checkout, how to set up WooCommerce test mode, WooCommerce grouped product, WooCommerce variable product and the best WooCommerce extra product options.