WooCommerce: Hide Products @ Shop Page

A client wanted to show only featured products on the shop page. While adding featured products is very easy (just use the WooCommerce shortcode in the page content), it seems very difficult to remove the “default” product loop. Here’s what I did.

WooCommerce Remove Loop at Shop Page
WooCommerce Remove Loop at Shop Page – the old way (commenting out core code). Thankfully there’s a better solution!

PHP Snippet: Hide All Products @ WooCommerce Shop Page

Please note: “Product Catalog” > “Shop page display” must be set to “Show products” in the WordPress > Appearance > Customizer > WooCommerce admin settings. Following snippet won’t work if you only have product categories @ product page.

To hide the “No products were found matching your selection” message that shows once the Shop page has no products to show, use this other snippet.

 * @snippet       Remove Product Loop @ WooCommerce Shop
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @community     https://businessbloomer.com/club/

add_action( 'pre_get_posts', 'bbloomer_remove_products_from_shop_page' );

function bbloomer_remove_products_from_shop_page( $q ) {
	if ( ! $q->is_main_query() ) return;
	if ( ! $q->is_post_type_archive() ) return;
	if ( ! is_admin() && is_shop() ) {
		$q->set( 'post__in', array(0) );
	remove_action( 'pre_get_posts', 'bbloomer_remove_products_from_shop_page' );

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages
    I’ve created a visual HTML hook guide for the WooCommerce Archive Page (which is the same page for the Shop, Category, Tag pages). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can […]
  • WooCommerce: Hide Prices on the Shop & Category Pages
    Interesting WooCommerce customization here. A client of mine asked me to hide/remove prices from the shop page and category pages as she wanted to drive more customers to the single product pages (i.e. increasing the click-through rate). As usual, a simple PHP snippet does the trick. I never recommend to use CSS to “hide” prices, […]
  • WooCommerce: How to Remove the “Default Sorting” Dropdown
    If the WooCommerce product sorting functionality (“Default Sorting” dropdown) is a waste of space or you don’t need that select box at all, you may want to remove it. No matter if you prefer custom code or a simple plugin – hiding the product sorting dropdown is a piece of cake. Enjoy!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

62 thoughts on “WooCommerce: Hide Products @ Shop Page

  1. Thanks for this, very helpful.

  2. Awesome, thanks. Being looking for this all morning!

    Well done

  3. Thanks Rodolfo for this further help. I don’k ask you the solution …. but only some tips to add product variations. The array shouldn’t be 0 but contain all product variation 🙂
    Bye Stefano

    1. Wrong post maybe?

  4. Hey,

    Thank you for the provided solution. I just want to share my solution with you and anybody else that maybe want to hide the Woocommerce notice “No products were found matching your selection.”. You can insert below line to end of your function to hide the notice without inserting the CSS to hide it.

    remove_action( 'woocommerce_no_products_found', 'wc_no_products_found' );

    1. Nice

      1. Hi Mahmood
        Is there a way to only hide the message on shops front page? It’s nice to be able to have the message in empty categories…


  5. Thanks Rodolfo for this code.
    Is it possible to apply this only to category and custom-taxonomy pages?

    1. Fahad, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  6. thank you. With you snippet, the default product list on my shop page disappeared, I then added the woo shortcode to display my own custom product list there. But the product filter does not work with woo shortcode.
    Is there any solution.
    Thank you

    1. Hello Quy, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  7. Snippet seems to no longer work. Tried on WC 3.7 – it still showed the products on the Shop page.

    1. Danny, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!


  8. Uau! Perfect for me!
    This was a huge tip! Thanks a lot!

    1. Great!

  9. After updating to PHP 7.2 I get the following errors.

    “Use of undefined constant ‘woocommerce_no_products_found’ – assumed ‘‘woocommerce_no_products_found’’ (this will throw an Error in a future version of PHP)”

    1. Hi Nick, I’m not sure this is linked to my snippet to be honest. Can you disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!


  10. Hi, I want to remove grid products from my first shop page, but I want see grid products in products category. by this snippet every grid products removed. what can I do?!

    1. Hello Shohreh, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  11. Hi Rodolfo, I need to automatically delete woocommerce products that exceed a certain time. For example, articles that have been stopped since the last 4-hour update must be deleted. Do you know how to do it?

    1. Hello Rocco, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  12. whaou thanks Rodolfo for this solution….I am looking for a solution since 1 week, you saved my week….congrat

    1. Excellent 🙂

  13. Oh my god THANK YOU , I’ve been looking for a solution to this for days… this works PERFECTLY!!!

    1. Thank you Scott 🙂

  14. Hi, thanks for this snippet! And for many others I’ve found useful. What awesome work you do! 🙂

    I think I found a way around the problem Reese had earlier, but couldn’t reply to it so I’m replying in a separate thread here. The problem was for her (him?), that the infobox saying “no products matching your selection” would appear and the PHP/CSS snippet you provided did not remove it for some reason.

    Well I had the same problem and I tweaked the snippet just to see if a separate declaration would do the trick – and tadah, now it works.

    So instead of

    if ( is_shop() ) {
    echo '<style>p.woocommerce-info{display:none}</style>';

    I now have

    $bool = is_shop();
    if ($bool = true) {
    echo "<style>p.woocommerce-info{display:none;}</style>";

    The annoying product loop is finally gone! Thanks a million!

    1. Thank you 🙂

  15. Unfortunately shortcodes do not work after the code, I can not customize a page with page builder origin. 🙁

    1. Hey Renato, thanks so much for your comment! I guess can you not use another WP page?

  16. Hi Rodolfo,

    I’m using your solution to remove the product loop from the shop page and it works fine, but it causes an issue with the product search result page when there are no results.

    I’m using the Advanced Woo Search plugin and it works perfect except this issue. When there aren’t products found, a page with only menu and footer is returned. If I remove your code, I get the normal No products found page. But I need to keep the product loop removed.

    Any idea how to fix this behavior?

    Big thanks for your time!


    1. Angel, thanks so much for your comment! Unfortunately this is custom troubleshooting work and I cannot help here via the blog comments. Thanks a lot for your understanding! ~R

  17. Doh!

    Rodolfo, the reply link is gone for me so I’ll make a “new” comment. I’m on WC 3.0.7 and WP has also been upgraded to 4.7.5..

    1. Don’t know what to say – it works on my test site. It could be your theme is customized. If you disable all plugins and switch theme to 2016, does this work?

    2. I went in and removed the code from wc-template-functions.php that was causing the fatal error when I added your snippet, activated the snippet and even ***then*** I see the “no products were found” message at the bottom of the shop when using the Bridge theme.. Changed to twenty-fourteen and it’s fine. Even with twenty-14 active though, if I have the conflicting line of code in wc-template-functions.php, your snippet provokes a fatal error: “Cannot redeclare wc_no_products_found() (previously declared in /home/twigling/public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php:2363)”.

      1. Hey Reese, I did my best 🙂 At this stage I would need to take a look at your website files, which unfortunately I can’t offer in this place. Sorry 🙂

  18. OMG!! I have wasted days trying to figure this out. THANK YOU!!! I tried adding the code to hide “No products were found matching your selection” where exactly does this go?

    1. Hey Bright thanks so much for your lovely comment! You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: https://businessbloomer.com/woocommerce-customization-hangout/. Hope this helps!

  19. Dear Lord!
    Thank you very much, I spent a huge amount of time trying to get this done, until I reached your site!

    1. Muchísimas gracias Alberto! Your feedback is much appreciated 🙂

  20. Hey Rodolfo,

    I tried method #1 on the latest WC and Storefront but it doesn’t work. The products are not rendered but it also gives an info message that no products were found which is not optimal of course. I can’t find any unique class so I can hide the info element for just the shop page.



    1. Hey Ben, thanks for your feedback! I just tried the snippet on latest WC & Storefront and products get removed from the Shop page correctly.

      However, yes, you’re right, a notice appear also: “No products were found matching your selection” you could hide that with simple PHP+CSS:

      if ( is_shop() ) {
      echo '<style>p.woocommerce-info{display:none}</style';

      Let me know!

      1. Hello, and thank you for the above code, I am using method one but via a Snippets plugin so as not to edit the functions.php directly (I do the same for css).

        Can you please explain where I should put the snippet I am replying to here to remove the “NO PRODUCTS WERE FOUND MATCHING YOUR SELECTION.” -message, it’s not clear to me whether it is CSS or PHP or whether I need to put it in both.

        Thank you so much for any help you can provide 🙂

        1. Hey Reese! “Method 1”, the one you should use, is purely a PHP snippet 🙂 And I’m afraid it’s not missing any brackets 🙂 Let me know

          1. Thank you, I did use method 1, I am referring to the:

            if ( is_shop() ) {
            echo '<style>p.woocommerce-info{display:none}</style';

            where should I put it, as in your comment you say ” you could hide that with simple PHP+CSS” ??? and I believed the end-style tag was missing a


            but I could be wrong.

            1. add this as a php snipped does not have any effect, it still says “NO PRODUCTS WERE FOUND MATCHING YOUR SELECTION.” at the bottom of the shop page, with or without the added > bracket.

              1. Gotcha 🙂 See, we’re talking about 2 different things. In this article I show how to remove the products, while you’re asking how to remove the message – which I guess it comes as a result of removing all products 😀

                I will add the fix to this in a minute (Snippet #1).


      2. PS. I tried adding as php, I think your snipped is missing an end bracket > ? Anyway still didn’t work, and it doesn’t seem like it belongs as is, as css either…?

        1. Replying here because it’s getting too skinny in the other comment sub-thread.

          I added the new snippet and this is what I got: “Don’t Panic

          The code snippet you are trying to save produced a fatal error on line 13:

          Cannot redeclare wc_no_products_found() (previously declared in /home/twigling/public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php:2351)
          The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

          Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.”

          I guess I would need to go find where this other declaration happened and see what it tells to do rather than /do nothing?

          1. Reese, what version of Woo are you using?

              1. That’s the WordPress version 🙂 Version of WooCommerce?

  21. Hey Rodolfo,
    I tried this based on your recommendation in the Facebook group, but it didn’t work for me. The file isn’t exactly the same anymore so it’s no longer on line 62 (or line 52 like your screenshot shows ;)) but I found it and replaced it and nothing happened. Also, my sidebar is now displaying under my products (even at full width screen). Can you give me another tip?


    1. Hey Fran, thanks for letting me know this! I’ll take a look and send you a fix soon 🙂

      1. I just updated the blog – let me know if this works for you (“Method 1”)!

  22. Hi Rodolfo,
    I have found a problem with this solution. When I implement it by commenting out the line of code as per your tutorial, I notice that this prevents any products from ever displaying on ALL OTHER Product category pages!

    It seems that commenting out this line effects how woocommerce loads products for the WHOLE site??
    Were you aware of this? Or is this just me??


    1. Anna, I appreciate your comment! You’re indeed correct, my fix was affecting all the loop/archive pages. I just made an edit, it would be great if you could let me know if this fixes it for you 🙂 Thank you!

  23. I meant the Sort order drop down. We added another condition to two of the if statements.

  24. How do we hide the line with the selection drop down? If I comment it out then go back and click on Categories nothing shows up on those pages.

    1. Scott, thanks for your query. What do you mean by “selection dropdown”? Can you show me a screenshot?

Questions? Feedback? Customization? Leave your comment now!

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *