WooCommerce: How to Hide a Category (The Easy Guide for Beginners)
So, you’re using WooCommerce to power your online store – awesome! But maybe you have a category you don’t want to show to everyone *just yet*. Perhaps it’s a new product line still under development, a VIP category only for specific customers, or simply a seasonal collection you want to unveil at the right time. Whatever the reason, hiding a WooCommerce category is a common task, and this guide will walk you through it step-by-step.
We’ll cover the easiest methods for beginners, avoiding complex code edits whenever possible. Let’s get started!
Why Hide a WooCommerce Category? Real-Life Examples
Before we dive into the “how,” let’s solidify *why* you might need this. Understanding the reasoning helps you choose the best method for your needs.
- Launching Soon: Imagine you’re about to launch a new line of handmade candles with unique scents. You want to work on the product details, images, and descriptions *before* the public sees them. Hiding the “Luxury Candles” category allows you to perfect everything behind the scenes.
- VIP Access: You run a subscription box service and offer exclusive products only to members. You might have a “Subscriber Exclusives” category visible only to logged-in subscribers with the correct role. Hiding this category from regular visitors maintains the exclusivity.
- Seasonal Products: It’s October, and you’re prepping for your Christmas decorations line. You’ve created a “Christmas Decorations” category but don’t want it visible until November. Hiding the category allows you to get everything ready in advance without spoiling the surprise.
- Testing & Development: You’re trying out a new product type and want to ensure everything is working correctly *before* customers see it. Hiding the category allows you to test the product, cart, and checkout process without impacting the customer experience.
- Shop and search results: This is the default, making the category visible everywhere.
- Shop only: The category will only appear on the shop page.
- Hidden: This is what you want! Selecting “Hidden” prevents the category from showing up on your shop page, in category lists, and in search results.
- Hide Categories from Guest Users: Make categories visible only to logged-in users.
- Hide Categories Based on User Roles: Show categories only to users with specific roles (e.g., “Subscriber,” “VIP Customer”).
- Specify Individual Categories to Hide: Select the exact categories you want to control.
- Granular Control: You can hide categories from specific user groups, not just everyone.
- Dynamic Visibility: Categories can automatically appear or disappear based on user login status or other conditions.
- User-Friendly Interface: Plugins provide a visual interface to manage category visibility without needing to edit code.
Method 1: Using WooCommerce Category Visibility Settings (The Simplest Way)
WooCommerce itself offers a simple, built-in way to control category visibility. This is often the easiest and most straightforward method for basic needs.
1. Navigate to Products > Categories: In your WordPress dashboard, go to “Products” then click on “Categories.”
2. Find the Category You Want to Hide: Locate the specific category you want to hide from your store.
3. Edit the Category: Click the “Edit” link under the category name.
4. Change Visibility: Look for the “Visibility” setting. You’ll likely see three options:
5. Update the Category: Click the “Update” button at the bottom of the page.
Important Note: While this hides the category from normal browsing and search, it doesn’t prevent direct access. If someone knows the direct URL (e.g., `yourstore.com/product-category/hidden-category/`), they can still visit the category page.
Method 2: Using a Plugin (For More Control and Flexibility)
For situations where the built-in visibility option isn’t enough, plugins offer more advanced control. Many free and premium plugins can help you hide categories based on user roles, logged-in status, and other criteria.
Example: Using “Category and Product Visibility Control” (Free Plugin)
This is just one example, but the principles apply to many similar plugins.
1. Install and Activate the Plugin: Go to Plugins > Add New in your WordPress dashboard, search for “Category and Product Visibility Control” (or similar plugin), install and activate it.
2. Access the Plugin Settings: The location of settings varies by plugin, but it’s usually found under “WooCommerce” or a separate menu item.
3. Configure Visibility Rules: This plugin will likely offer options to:
4. Save Your Settings: Make sure to save the changes you’ve made in the plugin’s settings.
Why use a plugin?
Method 3: Using Custom Code (For Advanced Users – Proceed with Caution!)
If you’re comfortable with code, you can use custom code snippets to hide categories. However, this method is generally not recommended for beginners. Mistakes in code can break your website. Always back up your site before making changes.
add_filter( 'get_terms', 'hide_woocommerce_categories', 10, 3 );
function hide_woocommerce_categories( $terms, $taxonomies, $args ) {
$hidden_categories = array( ‘category-slug-to-hide’ ); // Replace with the slug of the category you want to hide
if ( ! is_admin() && is_array( $taxonomies ) && in_array( ‘product_cat’, $taxonomies ) ) {
foreach ( $terms as $key => $term ) {
if ( in_array( $term->slug, $hidden_categories ) ) {
unset( $terms[ $key ] );
}
}
}
return $terms;
}
How to use this code:
1. Access Your `functions.php` File: Edit the `functions.php` file of your active theme. Again, back up your site first! This file is located in `wp-content/themes/your-theme-name/functions.php`. You can access it via FTP or the WordPress theme editor.
2. Paste the Code: Paste the code snippet at the end of the `functions.php` file.
3. Replace `’category-slug-to-hide’`: In the `$hidden_categories` array, replace `’category-slug-to-hide’` with the slug of the category you want to hide. You can find the category slug on the category edit page (under the name field). If you want to hide multiple categories, add more slugs to the array: `array( ‘category-slug-to-hide-1’, ‘category-slug-to-hide-2’ )`
4. Save the File: Save the `functions.php` file.
Why is this method less desirable for beginners?
- Risk of Errors: A small error in the code can break your site.
- Maintenance: You need to maintain the code snippet. If your theme updates, you might need to re-add the code.
- Complexity: Understanding the code requires some programming knowledge.
Important Considerations for Code Snippets:
- Use a Child Theme: Never edit your parent theme’s `functions.php` file directly. Always use a child theme. This prevents your changes from being overwritten when the parent theme updates.
- Test Thoroughly: After adding the code, test your website thoroughly to ensure everything is working correctly.
- Comment Your Code: Add comments to explain what the code does. This will help you (or someone else) understand it later.
Choosing the Right Method
- For simple hiding: Use the built-in WooCommerce category visibility settings.
- For granular control and ease of use: Use a plugin.
- For advanced users who understand code and need highly customized solutions: Use custom code snippets (with caution!).
Hiding a WooCommerce category is a relatively simple task, but understanding the available methods and their implications is key to choosing the right approach for your needs. Good luck!