Categories

Thursday, October 3, 2024
#919814419350 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

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.

 

therichpost
the authortherichpost
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 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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