You don’t always need additional plugins to manage the product visibility in your WooCommerce store.
For simple use-cases, you can use WooCommerce’s built-in settings to control which products appear in your shop, search results, and for specific customers.
For use-cases, you can add our code snippets. For example, you might need to hide individual items and entire product categories or restrict visibility based on user roles. While it might seem complicated, it’s absolutely possible to do so without any plugins.
Let’s explore how you can leverage WooCommerce’s core functionality to create a more tailored shopping experience for your customers.
What are hidden products in WooCommerce?
Hidden products in WooCommerce are items that exist in your store’s database but don’t appear on your main shop page, category pages, or search results. These products remain accessible via direct URL links (unless additional measures are taken).
Hidden products typically share these characteristics:
- Invisible to some or all users browsing your store
- Potentially excluded from search engine indexing
- Manageable through various visibility settings
The method you choose depends on your specific business requirements and how you want customers to interact with your inventory.
When to use code instead of a plugin?
If your business requirements are simple – you just want to hide products – and you don’t need to worry about SEO because your store is private, then you don’t need a plugin in our opinion — one of our small code snippets will do!
Let’s dive in!
How to hide individual products in WooCommerce without plugins
Hiding individual products in WooCommerce is straightforward using the platform’s built-in settings. This method is perfect when you need to temporarily remove specific items from your store’s catalog without deleting them completely.
WooCommerce includes a native “Catalog Visibility” setting that lets you control whether products appear in your shop pages and search results. Here’s how to use it:
- Log into your WordPress admin dashboard and navigate to All Products in the left sidebar menu.

- Find the product you want to hide from your list and click Edit to open the product editing screen.

- On the right side of the screen in the Publish section, find the Catalog visibility option (by default set to “Shop and search results”).

- Click the Edit link next to this visibility setting and select the Hidden option from the dropdown menu. Click OK to confirm your selection.

- Click the Update button to save your changes.
Important limitations to know about
This method comes with a few important limitations you should be aware of:
- Products hidden this way will not appear on your shop page, category pages, or in search results.
- They will still be accessible via direct URL links, meaning if someone knows the URL (or bookmarked the product URL), they can still view and purchase the item.
- Search engines may still index these products unless you use additional SEO settings. SEO plugins will automatically do that for you.
- Hiding products one by one using this method can become tedious if you have many items to hide. For larger collections, consider a “bulk editor” plugin that can do this for multiple products in one go.
How to hide a whole product category in WooCommerce with code
To hide both a category and its products in WooCommerce without plugins, you’ll need to use code snippets that filter out products from specific categories. You’ll need to add 2 code snippets to achieve that.
Snippet 1 of 2
Add the code snippet below to your child theme’s functions.php file:
add_action( 'pre_get_posts', 'sw_hide_category_products_from_loops', 999 );
function sw_hide_category_products_from_loops( $query ) {
// Only target the front end's main query for products.
if ( ! is_admin() && $query->is_main_query() ) {
if ( is_shop() || is_product_taxonomy() || ( is_search() && 'product' === $query->get('post_type') ) ) {
// Append a tax_query condition that excludes the category by slug
$tax_query = (array) $query->get('tax_query');
$tax_query[] = [
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => [ 'your-category-slug' ], // Change to the correct category slug!!
'operator' => 'NOT IN',
];
$query->set('tax_query', $tax_query);
}
}
}Code language: PHP (php)
Don’t forget to change the line that reads 'terms' => [ 'your-category-slug' ] to match your category slug.
To find the category slug, in the WordPress admin, go to Products → Categories. You’ll see a table with the image, name, description, slug, and count of each category. Just copy the slug and paste it in the code.
If you don’t want to exclude the categories globally (shop/tax/archive/search), you can replace if ( is_shop() || is_product_taxonomy() || ( is_search() && 'product' === $query->get('post_type') ) ) with more targeted checks, for example:
if ( is_shop() ) { ... }– Only on the main Shop pageif ( is_page( 999 ) ) { ... }– Only on the page with ID = 999if ( is_page( array( 999, 1001 ) ) ) { ... }– Multiple page IDsif ( is_page( 'your-page-slug' ) ) { ... }– A page slugif ( is_front_page() ) { ... }– The homepage
You can combine these with logical operators (|| for OR, && for AND) to precisely target where products are hidden.
Code snippet 2 of 2
We also need to hide the specific category from Category listings and widgets. Add the code snippet below to your child theme’s functions.php file:
add_filter( 'woocommerce_product_subcategories_args', 'sw_exclude_category_from_subcategories' );
add_filter( 'woocommerce_product_categories_widget_args', 'sw_exclude_category_from_subcategories' );
function sw_exclude_category_from_subcategories( $args ) {
// You must use the *ID* of the category here, not the slug.
$args['exclude'] = array( 123 ); // Replace 123 with the actual category ID
return $args;
}Code language: PHP (php)
Don’t forget to change the line that reads $args['exclude'] = array( 123 ) to match your category ID:
- In the WordPress admin, go to Products → Categories.
- Hover over your target category or click Edit.
- Look in the browser’s address bar for something like tag_ID=123. That number (e.g. 123) is the category ID.

How to hide products in WooCommerce for logged out users (guests)
You can also hide products for guests ( = visitors who are not logged in). This can be done without a plugin by adding the below custom PHP code to your theme’s functions.php file:
add_action('pre_get_posts', function($query) {
if (!is_admin() && $query->is_main_query() && is_shop() || is_product_category() || is_product_tag()) {
if (!is_user_logged_in()) {
$query->set('post__in', [0]);
}
}
});Code language: PHP (php)
Your “shop” page will look like this to visitors who are not logged in:

How to hide products in WooCommerce based on user roles
Suppose you run a store where, when a user logs in with the “Member” role, they see extra items not visible to non-members. This can be done without a plugin by adding the below custom PHP code to your theme’s functions.php file.
This code will remove the “VIP Members Only” category from the store when the user role is not “Member”:
function sw_hide_vip_items_from_non_members( $query ) {
if ( is_admin() ) return;
if ( ! $query->is_main_query() ) {
return;
}
// Check the user's roles
$current_user = wp_get_current_user();
if ( ! in_array( 'member', (array) $current_user->roles ) ) {
// For non-members, exclude the "vip-members-only" category
$tax_query = (array) $query->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'vip-members-only' ),
'operator' => 'NOT IN',
);
$query->set( 'tax_query', $tax_query );
}
}
add_action( 'woocommerce_product_query', 'sw_hide_vip_items_from_non_members' );Code language: PHP (php)
Don’t forget to:
- Change
vip-members-onlyto your actual product category slug. - Replace
memberwith your custom role slug (e.g.premium_member,vip, etc.).
The downsides of hiding products in WooCommerce
While WooCommerce’s product hiding features are useful, they come with several limitations you should consider:
- Products hidden through standard visibility settings remain accessible via direct URLs, potentially creating security gaps for exclusive items.
- Hidden products may still appear in your site’s XML sitemap, affecting search engine indexing and possibly your site’s SEO performance.
- For stores with large inventories, managing hidden products becomes challenging without automated systems, especially when products need regular visibility changes.
- Inventory reports might not accurately distinguish between visible and hidden products, complicating stock management decisions.
- The inconsistent appearance of products can confuse customers who find items through external links but not through your main navigation.
- Custom code solutions require careful implementation and testing to avoid breaking your store functionality.
Now you know how to hide products without plugins
You’ve learned powerful code snippets or methods to control product visibility in WooCommerce without extra plugins:
- Hiding individual products using core WooCommerce catalog visibility settings
- Hiding entire categories with custom code snippets
- Hiding products for logged out users (guests)
- Restricting products based on user roles.
When implementing code-based solutions, always use a child theme or a plugin for your modifications!