Is there any way to hide products that have no thumbnail, I’ve tried this code but doesn’t work.
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' => '>'
)));
}
2
Answers
Add this code into your active theme
functions.php
fileThis will make sure that the posts with
_thumbnail_id
has a value.This will ensure that the meta_value has a value.
If you want something more general.