WooCommerce: Hide products without featured image

When you’re creating an online store there are many tasks to perform, settings to configure and products to create or import, especially the latter.

Especially when you import products from a catalog of your supplier or your own product sheet from inventory, not all fields are imported, and especially delicate is the image of the product.

We live in a visual world, in which no one NOBODY, will buy a product without an image that shows its appearance and characteristics.

WooCommerce, by default, can put a temporary image, or placeholder as it is usually called, on products without an image, but assume it, you are not going to sell that product, and in the process give a pitiful image of your online store, like an unfinished Ecommerce, poor, sad, something is wrong, unreliable.

This happens when there is no image associated with your product on the product creation screen.

So what I propose is a fairly reasonable solution Ias i see it: Do not show in your online store products that do not yet have product image. Simple don’t you think?

To achieve this you just have to add a little code at the end of the functions.php file of the active theme (child), or if you prefer as a customization plugin, this one:

%MINIFYHTMLd5bdf17e41acd4f2de735488fe385b8a53%
/* Hide products without featured image */ add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' ); function custom_pre_get_posts_query( $query ) { $query->set( 'meta_query', array( array( 'key' => '_thumbnail_id', 'value' => '0', 'compare' => '>' ))); }

Save the changes and from this moment on any product that does not have an associated image will not be shown in your Ecommerce.

When you add an image it will magically appear, well, thanks to the code above 😉

Click to rate this post!
[Total: 1 Average: 5]

Leave a Comment

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

Scroll to Top Skip to content