Hello,
I am currently using the Woodmart product blocks feature to display products on my site. I want to modify the general product query used by these blocks so that products without a featured image are excluded from the results.
I’ve tried the following code using the woocommerce_product_query action:
add_action('woocommerce_product_query', 'exclude_products_without_featured_image');
function exclude_products_without_featured_image($q) {
$meta_query = $q->get('meta_query');
$meta_query[] = array(
'key' => '_thumbnail_id',
'compare' => 'EXISTS',
);
$q->set('meta_query', $meta_query);
}
This approach works for the main WooCommerce product query, but users still see products with placeholder images inside Woodmart product blocks.
Is there a recommended way or filter hook specific to Woodmart blocks to exclude products without a featured image? Or could you provide guidance or relevant code snippets to customize the product query these blocks use to avoid displaying products without thumbnails?
Thank you for your assistance!
Rob