WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)

Nevermind I (think) I got it…

$args = array(
    'post_type' => 'product',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'product_cat',
            'field'    => 'slug',
            'terms'    => array( 'ring' ),
        ),
        array(
            'taxonomy' => 'product_tag',
            'field'    => 'slug',
            'terms'    => array( 'black', 'men' ),
            'operator' => 'AND'
        ),
    ),
);

Missing the 'operator' => 'AND' key value pair

Leave a Comment