I want to use the WP_Query()
class to filter some of my posts. The problem I am facing now is handling the taxonomy query. Normally, the WP_Query()
only handle one relationship for tax_query()
(either AND or OR), but what I need is mixed use of these relationships on the tax_query()
, how can achieve it?
eg
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'taxonomy1',
'field' => 'slug',
'terms' => array( $term )
),
array(
'taxonomy' => 'taxonomy3',
'field' => 'slug',
'terms' => array( $term3 ),
'operator' => 'IN',
)
// below i want to use OR relationship
'relation' => 'OR',
array(
'taxonomy' => 'taxonomy4',
'field' => 'slug',
'terms' => array( $term4 )
),
array(
'taxonomy' => 'taxonomy2',
'field' => 'slug',
'terms' => array( $term2 ),
'operator' => 'IN',
)
)
I know the code above is not working, do I need to use WP_Query()
filter to do it? Any idea?