Home > WooCommerce > Docs > How to Hide Category in WooCommerce Product Page

How to Hide Category in WooCommerce Product Page

Last updated: September 01, 2024
Written and researched by experts at AvadaLearn more about our methodology

By Sam Nguyen

CEO Avada Commerce

WooCommerce categories help you organize your content so that your consumers can easily find what they’re looking for. However, not all of them should be shown on the site. Sometimes you might have items that you don’t want to publicize on your shop page. This is especially true if you have a long list.

What happens if you hide the WooCommerce shop page’s display categories? It will help you in keeping your homepage cleaner and more structured. We’ll show you three alternative ways to hide categories in your WooCommerce store in this post.

Let’s get started!

Why do you need to hide categories in WooCommerce product pages

Before we get into the steps, we’ll go over why you should hide categories on the WooCommerce shop page. You can benefit from concealing categories in your WooCommerce shop in various ways as an online store owner.

  • Allow you to create private products
  • Allow selling products to specific users/customers/clients
  • Suitable for developing a members-only club in store

    How to Hide Category in WooCommerce Product Page

    Method 1: Using the default WooCommerce feature to hide WooCommerce categories

Step 1: Access to WooCommerce Product Catalog

WooCommerce allows you to customize how your products are displayed on a Shop page. You can display the WooCommerce Shop page in a unique manner.

For this, go to Appearance > Customize > WooCommerce.

Step 2: Customize category display modes

After accessing the Product Catalog, you can display only one category, the category with products or only products.

There are three customization modes as follows:

  • Show products: All the products will be listed
  • Show categories: All the categories will be listed
  • Show categories and products: Both products and categories will be listed.

customize category display modes

Step 3: Save changes

Once customizing, click Publish to save changes.

Method 2: Using shortcode to hide WooCommerce categories

You can also hide categories in the WooCommerce product page by adding this shortcode snippet below in the currently active theme’s functions.php file.


<?php
 
/**
 * Show products only of selected category.
 */
function get_subcategory_terms( $terms, $taxonomies, $args ) {
 
	$new_terms 	= array();
	$hide_category 	= array( 126 ); // Ids of the category you don't want to display on the shop page
 	
 	  // if 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->term_id, $hide_category ) ) { 
			$new_terms[] = $term;
		}
	    }
	    $terms = $new_terms;
	}
  return $terms;
}
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );

Method 3: Using a plugin to hide WooCommerce categories

In this method, we use the WooCommerce Protected Categories plugin to hide categories on the shop page. We use this plugin because WooCommerce Protected Categories is a more straightforward way to hide a WooCommerce category. Two highlight features of this plugin are:

  • You can select which categories to hide right from your WordPress Dashboard You can decide whether to hide categories from the shop page completely or show them but requires customers to enter a password or login to access the protected categories or its products.

Now, we’re going to dive into it step by step.

Step 1: Install and activate the plugin

First of all, you need to download the plugin from barn2.com. Once downloaded, install the plugin in the normal way by going to Plugins > Add New and upload the zip file. Then, find this plugin and activate it.

example of step 1

Step 2: Plugin settings

In the next step, go to WooCommerce > Settings. The newly opened page is where you’ll need to enter your license key.

example of step 2

The first option in settings here is category visibility. If we uncheck these two boxes - show protected categories & products in the public-facing - store and show protected categories & products in navigation menus, any protected categories and products will not show up on my shop or categories page.

Step 3: Choose which categories to hide

Now to protect a specific category, we are going to go to the category area of WooCommerce. For this, access to **Products > Categories. **

example of step 3

Then, on the Product categories page, you can choose which category you want to hide by clicking on Edit in this category.

Step 4: Edit categories visibility

example of step 4

At the newly opened page, you will be able to either make a new category to house your hidden items or you can alter an existing category. Whichever method you choose, if you scroll down to the bottom of the page, a new section is added by the WooCommerce Protected Categories plugin called Visibility. Click the Protected option, and choose between:

  • Password protected: If visitors want to see the category, they need to enter a password. If necessary, you can create several passwords to open the category.
  • User roles: Your category will only be accessible to specific user roles.
  • Users: Your category will only be accessible to the users you select here.

Once the setup is done, click Update.

Once you’ve hidden one or more categories, go to WooCommerce > Settings > Products > Protected categories to configure a few more basic settings. Category Visibility is a very significant group of settings.

Uncheck both options if you want to remove a WooCommerce category from the shop page totally. On the other hand, tick both boxes if you want to show the category but require users to enter a password or login to view its contents.

How can people access the hidden categories in WooCommerce

Once you’ve hidden categories from the WooCommerce shop page, there are two methods to allow consumers access to them.

Providing access to WooCommerce password protected categories

Adding the shortcode [category_login] to any page to create a central category login form. Customers will be directed to the hidden category using the password they provided, and they will be able to see the protected category and products on the main WooCommerce shop page.

As mentioned before, if you tick the ‘Catalog Visibility’ box to make the hidden categories and products visible on the WooCommerce shop page, customers must provide a password to view the content.

Providing access for user or role protected WooCommerce categories

The other way to give access to protected categories is with the user and user roles options in the specific categories settings. Back to WooCommerce > Products > Categories, go to edit the category, and come down to the visibility section. Then, we can give access to a group of users by putting their usernames, or another way is to give user roles access. For this, just select the user role, and anyone with that role would be able to access the category.

When a client with the appropriate privileges login into their user account, user, and role restricted categories, their products will show automatically. The hidden categories and products will then be visible everywhere in your store, including the main WooCommerce shop page, navigation menus, and widgets. The hidden categories will be invisible to all other users.

Top 4 WooCommerce plugins to hide categories in product pages

WooCommerce Products Visibility

plugin 1

With the WooCommerce Products Visibility plugin, you can decide which products will be visible site-wide for each user role. This is the only plugin that offers you combined visibility roles. That is, for a particular role, you can hide products, categories, and tags all at once. Moreover, it is also the only plugin that hides the selected products, categories, and tags from your whole website, including menus, widgets, and even the theme.

Highlight features:

  • Consist of 4 modes: hide whole products, prices and/or add to cart buttons, payment methods, shipping methods
  • Hide or show products based on attributes (eg. color, size, etc.) for each user role
  • Combine product, tag, or category rules for each user role
  • Toggle role visibility on the backend to avoid clutter
  • Default logged user role for bulk actions

Price: $24

YITH WooCommerce Category Accordion

plugin 2

You can create a stunning and user-friendly accordion dropdown for your categories with this YITH plugin. Instead of using the standard category list widget, you may use this one instead. Besides a more attractive appearance, this plugin gives you more control over which categories appear.

Highlight features:

  • Allow setting a particular number or showing
  • Sort categories as you like by ID, by name, or by number of elements in the category
  • Freely choose where you want to show widget and shortcode
  • Allow selecting both customized menus and tags assigned to the products of the shop
  • Add accordion on everywhere of your site by using shortcode

Price: $59.99

Password Protected Categories & Store

plugin 3

Password Protected Categories & Store is an interesting option for restricting category access. You can use this plugin to lock your entire shop or just specific categories. This plugin also allows you to password-protect product categories, product tags, pages, products, or your entire website.

Highlight features:

  • Add multiple passwords for each category, tag, product, or page
  • Enable password protection for specific countries
  • Support password protection for the hierarchy of product categories
  • Support simple or custom login forms
  • Products belonging to password-protected categories will inherit the protection of related categories or tags

Price: $49

WooCommerce Password Categories & Shop Plugin

plugin 4

WooCommerce Password Protected Categories by Addify allows you to password protect your entire WordPress website, store section, particular categories, products, and Pages. You can set a password, hide the desired content from the public, and share the password with only a few users. You can also choose to rank password-protected pages in search results by allowing Google to crawl your protected pages.

Highlight features:

  • Create multiple passwords with comma-separated or CSV import
  • Create different passwords for different pages
  • Allow showing a custom background image on password-protected page
  • Customize password protect form heading & form opacity
  • Analytics report for each password to see if any password is being misused

Price: $35

Final words

It can be concluded that hiding categories in the WooCommerce product page are both necessary and beneficial. In this post, we’ve shown you three ways to hide categories, including using WooCommerce default features, shortcode, and plugins. However, the most suggested method is to utilize a plugin because it is easy to do and does not mess with the code too much. Before proceeding, you should consider which method is best for your store.

We hope you found this post informative and that you now have a better understanding of how to hide category in WooCommerce product page. Don’t hesitate to leave a comment for us if you’re still unclear about something!


Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.

Stay in the know

Get special offers on the latest news from AVADA.