I have multiple custom post types and each of them has multiples categories. I’m trying this code to display certain categories from all of the custom post types + regular post.
<?php query_posts( array(
'post_type' => array( 'post', 'miss_behave','emily_davies', 'gemma_patel', 'poppy_smythe' ),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => 4
),
array(
'taxonomy' => 'miss_behave_category',
'field' => 'term_id',
'terms' => 141
),
array(
'taxonomy' => 'emily_category',
'field' => 'term_id',
'terms' => 142
),
array(
'taxonomy' => 'gemma_category',
'field' => 'term_id',
'terms' => 143
),
array(
'taxonomy' => 'poppy_category',
'field' => 'term_id',
'terms' => 144
)
),
'showposts' => 4)
); if (have_posts()) : ?>
Which then the page doesn’t show anything. The page shows something only if I query the default post only.
Please help!
I figured it out. Setting ‘relation’ to ‘OR’ is important.