I need to build a complex query. I want to display all posts, and 2 different CPT posts in specific taxonomies. All of these posts need to have been checked to be displayed. The checkbox is added with ACF. My ACF checkbox is named highlight and the value needs to be yes.
So my query should display:
- all posts of all categories but with the ACF checkbox checked
- all post of the CPT1 with the taxonomy TAX1 and ACF checkbox checked
- all post of the CPT2 with the taxonomy TAX2 and ACF checkbox checked
So far I tried :
query_posts(array(
'post_type' => array( 'post', 'cpt1', 'cpt2' ),
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => 10,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'highlight',
'value' => '"yes"',
'compare' => 'LIKE'
)
),
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'TAX1',
'field' => 'slug',
'terms' => 'valueTAX1',
),
array(
'taxonomy' => 'TAX2',
'field' => 'slug',
'terms' => 'valueTAX2',
),
),
)
It's not working though :(
Any help would be so appreciated!
Thank yoou, Sandra