• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Hide WooCommerce products without a featured image from search results

Learn in this tutorial how to hide WooCommerce products that do not have featured image from search results using code.

By default, when the web visitor performs a search all WooCommerce products appear but you may prefer to hide the ones without featured image

Interested? Here’s how to do it.

Snippet to hide WooCommerce products without featured image from results

Add the following code at the end of functions.php or in your functionality plugin:

To see this and another 845 code snippets of this website, login or subscribe here.

In this code you use the hook pre_get_posts in combination conditional tags and the key _thumbnail_id.

Conclusion

As you can see, with a few lines of code you can hide WooCommerce product search results without featured image.

If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.

Benefits of being a subscriber. 🙂

PHP Products WooCommerce

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?