Home Wordpress Tricks Wp query display woocommerce product based on category name

Wp query display woocommerce product based on category name

by therichpost
0 comment
How to add custom meta title and meta description in Wordpress?

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.

 

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.