I am trying to pull product images that are assigned to a monthly-special product category. I tried 'category_name' => 'monthly-specials' and it does not appear to work correctly. Can anyone shed some light on what I did wrong and how to select a specific product category that the product is assigned to for the homepage?

<div class="owl-carousel owl-theme f-products">
      $args = array(
      'post_type' => 'product',
        'category_name' => 'monthly-specials',
      'stock' => 1,
      'posts_per_page' => 12,
      'orderby' =>'date',
      'order' => 'DESC' );
      $loop = new WP_Query( $args );
      while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
      <div class="item">
      <a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
      <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="My Image Placeholder" width="65px" height="115px" />'; ?>
      <h3><?php the_title(); ?></h3>
        <div class="item-footer">
      <span class="price"><?php echo $product->get_price_html(); ?></span>
      <span><?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?></span>
      </div><!-- /span3 -->
      <?php endwhile; ?>
      <?php wp_reset_query(); ?>

1 Answer 1


If these products came from WooCommerce, then most probably you’re using wrong taxonomy in your code.

WC products use product_cat taxonomy as categories, so you can’t use built-in categories to filter them.

Use this instead

 'product_cat' => 'category-slug-here',

and it should work correctly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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