WC displaying products from category

I’m currently working on shop page and custom product loop. With WP_Query I can succesfully display products based on meta_key and meta_val but i run into trouble.
Now i have to display all products from category and as argument i need to pass category_id. This is my code:

$args = array(
‘post_type’ => ‘product’,
‘posts_per_page’ =>12,
// get category by slug is working –
‘product_cat’ => ‘products-from-cat-40’,
);

I know that woocommerce have slightly different query arguments than wordpress so i’ve tried so far:

product_cat_id
product_cat
product_category
product_category_id
cat
cat_id
category_id

As ID i passed both integer and string but still nothing works. I’ve searched trough internet for list of viable Woocommerce WP_Query arguments and i couldn’t find it. Can anyone help? I’ll much appreciate.

Read more here:: WC displaying products from category

Leave a Reply

Your email address will not be published. Required fields are marked *