Saturday, July 11, 2020
therichposts@gmail.com
Wordpress Tricks

Wp query display woocommerce product based on category name

How to add custom meta title and meta description in Wordpress?

Wp query display woocommerce product based on category name

Views

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 freelance full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, Angular 8, Angular 9, Angular 10 Nodejs, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

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