Completely hide WooCommerce products from shop, product search and WordPress search

You can hide a WooCommerce product from the shop page and product search by choosing ‘Hidden’ in the ‘Catalog visibility’ options from the Publish metabox on a product page in the backend.

This is good and it hides the product as advertised from the shop and product search results but the product is still visible if searched from the regular WordPress search!

Woocommerce Hidden From Catalog
Product with Catalog Visibility set to Hidden

WordPress Search Results

So if you were to search your site with a dynamic URL parameter the product you had hidden would show in the search results.

add_action('pre_get_posts', 'wpse_187444_search_query_pre');
 * Hide Catalog Products Only In Search
 * @link
 * @since 1.7.0
function wpse_187444_search_query_pre($query) {
    if ($query->is_search() && $query->is_main_query()) {
        $tax_query = $query->get('tax_query', array());

        $tax_query[] = array(
            'taxonomy' => 'product_visibility',
            'field'    => 'name',
            'terms'    => 'exclude-from-catalog',
            'operator' => 'NOT IN',

        $query->set('tax_query', $tax_query);

So in the above code snippet (original source in the link value) a pre get posts filter is run on the main search query and any products which have Catalog Hidden set are not returned to the search results, add the code in your themes functions.php file.

Google Index

Another issue is that the hidden products are still index by Google and visible via an site Google search or sitemap. You have a couple of options to solve this issue.

  • You can set each product manually to noindex/nofollow in your SEO plugin per page
  • If you have many products to hide you can assign a category to the products and run a filter to exclude those products from being indexed. This example uses WordPress SEO – Yoast to set noindex.

Always recheck your sitemap or run a Google site search to check for hidden product content Hidden Woo Product