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:
/* 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' => '>'
)));
}
Code language: PHP (php)
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 😉
Thank you, thank you so much. Spent 5 hours looking for this, analyzing woocommerce files and even starting an advanced tutorial!
So how do you know what to use in the function? I mean: how did you get to “$query->set”?
thanks again!
The key here is the ‘key’ value established with the thumbnail_i = 0, where the code detects if there isn’t a thumbnail image
Hello,
The code works but the products are visible on the relateded products tab
How to hide them also there
Dennis,
I also would like to know this. Have you found out already? Please let me know what the solution is if you have it.
Thanks in advance!
Nick
Hello,
This solution works fine on the product pages, but when i use shortcode for recent products on my home page, the products without an image also show. Is there a way to fix that also?
Thanks in advance.
Nick Vinke
Have the save question here!