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.
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.
You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"
Does this snippet (still) work?
Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
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.
60 thoughts on “WooCommerce: Hide Products @ Shop Page”
Awesome, thanks. Being looking for this all morning!
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 🙂
Wrong post maybe?
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' );
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…
Thanks Rodolfo for this code.
Is it possible to apply this only to category and custom-taxonomy pages?
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!
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.
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!
Snippet seems to no longer work. Tried on WC 3.7 – it still showed the products on the Shop page.
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!
Uau! Perfect for me!
This was a huge tip! Thanks a lot!
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)”
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!
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?!
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!
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?
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!
whaou thanks Rodolfo for this solution….I am looking for a solution since 1 week, you saved my week….congrat
Oh my god THANK YOU , I’ve been looking for a solution to this for days… this works PERFECTLY!!!
Thank you Scott 🙂
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
I now have
The annoying product loop is finally gone! Thanks a million!
Thank you 🙂
Unfortunately shortcodes do not work after the code, I can not customize a page with page builder origin. 🙁
Hey Renato, thanks so much for your comment! I guess can you not use another WP page?
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!
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
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..
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?
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)”.
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 🙂
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?
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!
Thank you very much, I spent a huge amount of time trying to get this done, until I reached your site!
Muchísimas gracias Alberto! Your feedback is much appreciated 🙂
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.
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:
Let me know!
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 🙂
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
Thank you, I did use method 1, I am referring to the:
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.
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.
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).
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…?
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?
Reese, what version of Woo are you using?
That’s the WordPress version 🙂 Version of WooCommerce?
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?
Hey Fran, thanks for letting me know this! I’ll take a look and send you a fix soon 🙂
I just updated the blog – let me know if this works for you (“Method 1”)!
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??
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!
I meant the Sort order drop down. We added another condition to two of the if statements.
Oh I see – I already wrote a snippet for that: https://businessbloomer.com/woocommerce-remove-default-sorting-dropdown/
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.
Scott, thanks for your query. What do you mean by “selection dropdown”? Can you show me a screenshot?