Join WhatsApp ChannelJoin Now

How to Get Product Category Wise in WordPress

Hello Dev,

Today, i we will show you how to get product category wise in wordpress. This article will give you simple example of how to get product category wise in wordpress. you will learn how to get product category wise in wordpress.

It is very simple query to show products by specific categories. So let’s follow few step to create example of how to get product category wise in wordpress.

$args = array(
    'post_type'      => 'product',
    'posts_per_page' => 10,
    'product_cat'    => 'bags'
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    global $product;
    echo '<br /><a href="'.get_permalink().'">' . woocommerce_get_product_thumbnail().' '.get_the_title().'</a>';
endwhile;
wp_reset_query(); 

Recommended Posts