wordpress - fetch products if image is found in woocommerce? -


i want show image products in woocommerce.

my fetch query given below

$args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 9, 'orderby' =>'date','orderby' => 'rand' ); $loop = new wp_query( $args ); 

how can image products only?

are looking ?

<?php      $args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 9, 'orderby' =>'date','orderby' => 'rand' );     $loop = new wp_query( $args );     while ($loop->have_posts()) : $loop->the_post();         echo get_the_post_thumbnail($loop->post->id, 'shop_catalog');     endwhile; ?> 

updated

$args = array(                  'post_type' => 'product',                  'stock' => 1,                  'posts_per_page' => 9,                  'orderby' =>'date',                 'orderby' => 'rand',                  'meta_query'=>array(                     array(                         'key'=>'_thumbnail_id',                          'compare' => 'exists'                     )                 )             ); 

change arg product if has feature image.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -