WooCommerce Hide Category from Shop Page ( 4 Ways )

A shop page is the core of any e-commerce website, it displays various products and categories, allowing customers/users to browse through various items based on their preferences. A user-friendly, well-designed, and well-categorized shop page can help you increase your sales and conversions of your store products.

In the world of eCommerce, you never know what might catch your visitor’s attention and what won’t. Therefore, it is important to ensure that each element in your shop has a purpose and that only the things that are essential for your customers are visible.

Categories on the shop page are one of the most important elements that allow your customers to quickly find what they were looking for in your shop. And remember that a well-categorized shop will make it easier for a customer to find exactly what they need and make a purchase.

On the WordPress WooCommerce website, all product categories are displayed on the shop page by default, which is a positive aspect. However if a shop owner wishes to hide a specific category from shop page, they might wonder how to remove or hide a category from shop page.

Well, there is no built-in feature in the WordPress WooCommerce website that allows you to hide category from shop page, but in this brief guide, I will be showing you four ways through which you can easily hide WooCommerce product categories from the shop page.

Before you learn how to hide categories from the shop page, let’s first discuss why there is a need to hide category from a shop page.

Why to Hide WooCommerce Categories?

Suppose products from a certain category become out of the stock or you are not selling a category of products anymore or for a long period of time, then it’s necessary to hide this category in order to have a tidy and well-organized shop page.

Also, some shop owners might want to display different categories to different users depending on their role, for instance, the shop owner might want to keep certain categories away from website visitors and only show them to logged-in customers.

In addition, some seasonal categories may exist such as summer and winter clothing collections, therefore a shop owner might want to hide the summer clothes collection in winter or the winter clothes collection in summer. Hence there are a number of reasons why you might want to hide WooCommerce categories, now let’s look at how to do that in action.

Also Read: How to Remove Category from WordPress URL ( 4 Ways )

4 Ways to Hide Category from Shop Page in WooCommerce

In this comprehensive guide, I will be providing four easy ways to hide categories from the shop page. So let’s begin..!

1) Hide WooCommerce Categories via PHP Code Snippet

In the Products section of the WooCommerce plugin Dashboard, you will see that categories can only be deleted and no other options are available, but you want to hide them and not to delete them since you might need them in the future.

WooCommerce product categories

It is not necessary to rely on built-in functionality to hide a category in WordPress, as you can accomplish this using a variety of other methods. You can use PHP Code Snippet to hide category from shop page, to do so, log in to your WordPress Dashboard > go to WooCommerce > Products, here find the slug of category which you want to be hidden.

Copying the category slug

Now in the Appearance > Theme Editor, locate the theme function.php file. Copy and paste the PHP code below into the bottom of the function.php file, and then add the desired category slug there which you want to be hidden.

If you don’t know how to properly add code snippets in function.php file, you can first visit my guide on Editing functions.php in WordPress and then start editing your function.php file

add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( ' Add CATEGORY SLUG HERE ' ) ) ) { //pass the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

If you want to hide multiple categories on a shop page, include multiple categories in the code like this.

add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( ' ADD CATEGORY SLUG HERE ',' 2nd category slug', ' Third ',' And so on...' ) ) ) { //Add the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

Note: If in the future you wish change your theme then this code will be removed from function.php file, so it is better install Code Snippet plugin and add the above code there, in this way changing your theme won’t affect this code.

Once the PHP code is added to function.php file, update the file, now on the shop page you will notice that the category which you want to be hidden cannot be seen anymore.

2) Hide WooCommerce Categories From Users Based on their Role

To hide a certain category from non-logged-in users, add the following PHP Code at the bottom of your function.php file.

add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() && !is_user_logged_in() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( ' ADD CATEGORY SLUG HERE ' ) ) ) { //Add the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

You can use this code to hide a category of products from users who are not logged in to your site or you can use it to hide a category of products on which you are offering discounts to members only. So only the members of your site can access the discounted category of products on the shop page.

3) Hide WooCommerce Categories From All Website ( Including Widgets )

You can hide a WooCommerce category from shop page only using the methods described above, but if you want to hide a certain category from widgets, posts, and all other pages of your website, you’ll need to add the below code in function.php file.

add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( ' ADD CATEGORY SLUG HERE ' ) ) ) { //Add the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

4) Using a Plugin to Hide Categories On Shop Page

If you are looking for a simpler and more user-friendly way to hide WooCommerce categories from your shop page without having to work with code snippets, you can consider using a plugin like Hide Categories Or Products On Shop Page.

Hide Categories Or Products On Shop Page plugin

This method does not require any coding skills and is suitable for those who prefer a more straightforward approach. So here is how you can use this plugin to hide categories.

First of all, go to the plugins section of your website and click on Add New, in the search bar, type “Hide Categories Or Products On Shop Page”, now install and activate this plugin. Once the plugin is activated, you can access its settings from the WooCommerce settings page.

Searching for Hide Categories Or Products On Shop Page plugin in add new plugin area

Now, go to WooCommerce tab in your dashboard menu and you will see the Hide categories or Products option, click on it. There you will see a dropdown to select a category which you want to hide, you can also search the category there.

Once you have selected the category, below there will be checkbox labeled as Hide Category, check mark it, there will be another checkbox too for hiding product, you can also check mark it, which will not only hide category from shop page but also products within that category on shop page.

hiding category in plugins settings

Well, that’s it your selected category is now hidden on shop page.

FAQ( WooCommerce Hide Category from Shop Page )

How can I hide a category from the WooCommerce shop page?

To hide category from WooCommerce shop page, install and activate the “Hide Categories Or Products On Shop Page” plugin from the WordPress dashboard, then Navigate to WooCommerce > Hide Categories or Products option.

Choose the category you want to hide using the dropdown menu, check the “Hide Category” box to hide the category, and use the “Hide Product” option if you want to hide both the category and its products.

Does WordPress has built-in feature to hide Category from shop page?

You can hide categories from shop page using code. Until now, WordPress has no built-in feature to do so.

How do I hide multiple categories on shop page?

To hide multiple categories from a shop page, identify the Slug of these categories in the WooCommerce plugin category tab. then head over to function.php file located in Appearance >> Theme Editor, and paste the following code there:

add_filter( ‘get_terms’, ‘ts_get_subcategory_terms’, 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
if ( in_array( ‘product_cat’, $taxonomies ) && ! is_admin() &&is_shop() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( ‘ ADD CATEGORY SLUG HERE ‘,’ 2nd category slug’, ‘ Third ‘, (‘ And so on…’) ) ) ) { //Add the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

Wrapping it up

You can now easily hide WooCommerce categories from your shop page. In this guide, I have discussed four easy ways that you can use to hide categories from the shop page in WordPress. You can use any of them based on your requirement.

I hope you have learned all you need to know about the topics discussed in this article but if you are still unclear about how to hide WooCommerce categories from WordPress shop page, or if you are facing any issues related to this process, do let us know in the comment section below. We will be happy to guide you.

If you want us to cover other topics or issues in WordPress, please contact us through our Contact page. That’s it for this guide, thanks for reading. Have a great day….!

Hamza Afridi is a Full stack Web & WordPress developer and writer with 5+ years of experience. He is Founder of webtalkhub.com, a blog on web development, SEO, and digital marketing tutorials. He enjoys learning and sharing new technologies.

Leave a Comment