WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to retrieve the thumbnails for only certain products of my woocommerce, using products_tag,

this code is showing all products :

<ul class="products">
$args = array( 'post_type' => 'product', 'posts_per_page' => 5 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>

<?php global $post; echo "<p id = 'id_name'>" . $thePostID = $post->ID. " </p>";    ?>

<?php if (has_post_thumbnail( $loop->post->ID )) 
echo  get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); 
else echo '<img src="'.$woocommerce->plugin_url().'/assets/images/placeholder.png" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_catalog_image_width').'px" height="'.$woocommerce->get_image_size('shop_catalog_image_height').'px" />';

<?php endwhile; ?>

I try to add more arguments to the array inserting 'product_tag' but doesn't' work:

 $args = array( 'post_type' => 'product', 'posts_per_page' => 5, product_tag => 'shoes' );

How can i show only the products with the tag shoes ?

Thanks for your help

share|improve this question
up vote 0 down vote accepted

I found the answer, it was a typing mistake, you have to put

'product_tag' => 'wherever_tag_you_use' 

and it's works like charm

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.