Having numerous products can make your WooCommerce cshop page look promising. But it would look messy if not optimized. It’s also possible that your high-yielding products would fail to attract visitors and not make enough sales.
You cannot let it escalate and risk your hard work.
So, one of the practical solutions is to hide every product category that’s not bringing you sales. Or, hide from certain user roles, like editors, to make your website more functioning.
This will make it easier for customers to navigate and keep your homepage clean, resulting in higher conversions.
In this blog, we will talk about some code snippets to hide categories on your shop page and other scenarios.
We’ll also see a reliable solution you can opt to bulk edit and manage product categories.
Why hide categories in WooCommerce?
We’ll share a few significant reasons to hide categories in WooCommerce:
- Convey effective brand voice: You can display intended products and services to your audience and promote them to convey brand voice more creatively.
- Streamline shopping process: It can help visitors search for the desired product quickly and buy whatever they want.
- Declutter unnecessary products: It lets customers focus on the important ones. It also brings out brands’ aesthetics and helps marketing high-yielding products better.
- Enhanced customer experience: Your customers will stay long to browse your site longer and provide positive feedback. It eventually encourages them to revisit.
Overall, hiding categories can help in target marketing and boost sales in the long run.
Further, WooCommerce categories can help you organize your products. So that users can easily find what they’re looking for.
Note that not all categories need to be shown to the users, such as the ‘Uncategorized’ category in WooCommerce.
And, if you want to prevent certain products from being displayed in your shop, you can:
- Create a member-only store that allows only special and logged-in users to purchase the products.
- Sell products to specific users only, allowing them to access only after using a specific password.
- Create private products and send access to some of your customers via email.
WooCommerce hide category – doing it the default way and coding
You can use your default WooCommerce settings to hide categories in WooCommerce. In some cases, you’ll need some code snippets. Let’s look at the various scenarios:
Your visitors won’t be able to see that category or products that belong to it.
Hide all categories on the shop page
- Go to WordPress Admin panel > Appearance > Customize > WooCommerce > Product Catalog.
- Under the Shop page display, choose
Show products
and clickPublish
.
This will show all the products only and not categories.
Hide categories in product widgets
If you want to hide your current category from the product categories widget, use the following code in your functions.php
file.
But adding code is always risky. Refer to our doc on safely adding code snippets before you move ahead.
add_filter( 'woocommerce_product_categories_widget_args', 'storeapps_hide_current_cat_prod_cat_widget' ); function storeapps_hide_current_cat_prod_cat_widget( $args = array() ) { if ( is_product_category() ) { $current_cat_id = get_queried_object_id(); $args['exclude'] = $current_cat_id; } return $args; }
Hide categories from users
This is if you want to allow access for some categories only to specific users. The below code restricts user roles, such as ‘Subscriber’ and ‘Shop Manager’, from accessing the fashion category.
add_filter( 'woocommerce_product_query_tax_query', 'storeapps_hide_shop_categories_by_role' ); function storeapps_hide_shop_categories_by_role( $tax_query = array() ) { $user = wp_get_current_user(); // Get the current user object. $blocked_user_roles = array( 'subscriber', 'shopmanager' ); // Define an array of blocked user roles. $hidden_categories = array( 'fashion' ); // Define an array of hidden categories. if ( is_user_logged_in() && count( array_intersect( $blocked_user_roles, $user->roles ) ) === 0 ) { return $tax_query; } $tax_query[] = array( 'taxonomy' => 'product_cat', 'terms' => $hidden_categories, 'field' => 'slug', 'operator' => 'NOT IN', ); return $tax_query; // Return the modified tax query. }
Hide products from a WooCommerce product category
This is to remove products from categories instead of removing categories in the first place.
add_action( 'woocommerce_product_query', 'storeapps_exclude_categories_from_shop_page' ); function storeapps_exclude_categories_from_shop_page( $q ) { $tax_query = (array) $q->get( 'tax_query' ); $tax_query[] = array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( 'uncategorized', 'books' ), // Exclude products in the "uncategorized" and "books" categories. 'operator' => 'NOT IN' ); $q->set( 'tax_query', $tax_query ); }
That’s how you can hide categories on your WooCommerce store.
But your work is not done yet. You also need to manage multiple categories and that is difficult using default WooCommerce. You need a plugin that can do everything in just a few clicks.
So, the Smart Manager plugin can help you effectively manage categories on your WooCommerce store.
Let’s discuss it now.
How does Smart Manager help you better manage categories?
Smart Manager helps you manage multiple product categories, along with your entire store from one place. You can easily manage everything in seconds as it displays data in an Excel-like spreadsheet.
Key features:
- Copy categories from any record or other categories using the Bulk edit feature.
- Delete/duplicate all/selected products based on categories.
- Bulk assign/remove categories to products.
- Inline edit based on categories using the search filters.
- Export data based on categories.
- Advanced search filter to display product categories and bulk edit them.
- Advanced search filter to display blog posts and coupons based on categories.
- Edit/duplicate/delete selected blog posts and coupon categories.
and much more…
Conclusion
Hiding categories can be useful to make your shop page easier to use and manage. It also helps create a better customer experience, convey brand voice and navigate them smoothly.
Would you like us to add more code for different scenarios and plugins to hide categories? Reply in the box below.
FAQ
Can you hide out-of-stock products in WooCommerce?
Yes. It’s simple. You need to go to WooCommerce > Settings > Products > Inventory. Scroll down and check the box ‘Out of stock visibility’ box. That will hide your out-of-stock items from your catalog.
Does hiding categories affect SEO?
Hiding categories would not directly affect SEO. Though they aren’t visible, you still have those categories on your shop page. Customers will be able to find them when they search it. The point is hiding categories can provide a better user experience, resulting in better SEO ranking.
Is it good to hide categories for A/B testing?
Though you shouldn’t do it frequently, it’s advisable to analyze the impact on sales and user behavior by hiding a few product categories.