How to sort WP Query to display each product category? [Woocommerce]
Question
I have 12 “main” categories that my products fall under, I don’t want to display each product, only the parent category they are under. Is there an argument I can place in this query?
Here is what I have so far:
<?php
$product_loop = new WP_Query( array(
'post_type' => 'product',
'posts_per_page' => 12
)
);
?>
<section id="products-home">
<?php if($product_loop) : ?>
<div class="container">
<div class="row">
<?php while ( $product_loop->have_posts() ) : $product_loop->the_post(); ?>
<div class="col-md-3">
<?php the_post_thumbnail( 'full', array( 'class' => 'img-responsive' ) ); ?>
<h3><?php echo the_title(); ?></h3>
</div>
<?php endwhile; ?>
</div>
</div>
<?php endif; ?>
</section>
0
woocommerce, wp-query
8 months
0 Answers
94 views
0
Leave an answer
You must login or register to add a new answer .