Wordpress Tricks

Wp query display woocommerce product based on category name

Wp query display woocommerce product based on category name

wordpress
247Views

Hello to all, welcome to therichpost.com. In this post, I will tell you, Wp_query display woocommerce product based on category name.

Here is the code for Wp_query display woocommerce product based on category name and you can this code any of your wordpress theme’s template file:
<?php  
$args = array(
    'post_type'      => 'product',
    'posts_per_page' => 10,
    'product_cat'    => 'hoodies'
);

$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();
?>

 If you have any query related to wordpress or this post, then please do comment or email me.

 

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

Positive SSL