Thread Starter
TA003
(@ta003)
I’m using wooCommerce.
I’ve tried:
$args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'baby', 'orderby' => 'rand' );
This is working but it shows me items form the first category?
I’ve tried:
$args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'baby, red', 'orderby' => 'rand' );
But it seems to show only the products from the first category.
Thread Starter
TA003
(@ta003)
I found it! I’ve used your code and changed the taxonomy to ‘product_cat’. This is the full query:
$args = array(
'post_type' => 'product',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => array(20, 61, 74, 28),
'operator' => 'AND'
)
),
'orderby' => 'date',
'order' => 'ASC'
);
$loop = new WP_Query( $args );
Thanks for all the help!
You’re welcome. I’m glad you’ve got it resolved 🙂
It was not a category but a custom taxonomy that was the problem.
http://codex.ww.wp.xz.cn/Taxonomies#Custom_Taxonomies