Reputation: 1
I need a tax_query
that assigned to specific custom category and tags.
Below query showing all products but I need the products to a particular category.
Here tag="sale"
, category="look"
$args = array(
'post_type' => 'product',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'look' ),
),
array(
'taxonomy' => 'product_tag',
'field' => 'slug',
'terms' => 'sale',
),
),
);
$query = new WP_Query( $args );
Upvotes: 0
Views: 301
Reputation: 385
You can simply use this
$new = new WP_Query('category_name=look&tag=sale');
Upvotes: 1
Reputation: 5166
try to use something like this
$args = array(
'posts_per_page' => 5,
'post_type' => array('videos','image','audio'),
'category_name' => 'look',
'tag'=>'sale'
);
$loop = new WP_Query( $args );
Upvotes: 0