I have two taxonomies belonging to the same post type (posts).
Adventure - belonging to the category taxonomy Adventure - belonging to the holiday-type taxonomy
I want to run two queries:
$args = array(
'post_type' => 'post',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'holiday-types',
'field' => 'slug',
'terms' => 'adventure',
),
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'adventure',
),
),
);
$the_query = new WP_Query( $args );
Even though the terms are the same they have different posts associated to them.
This query only returns posts with the holiday-types taxonomy and not the category taxonomy too. If I comment out the array with the holiday types, then the taxonomy category shows the relevant posts.
I need them to both show together as well as with pagination.
'paged' => get_query_var('paged')
I have read that i need to add this to the first array but i guess i cant test this until i get the loop working correctly first.
Any ideas where I am going wrong please?
Ok. I have got somewhere with this now but the pagination doesn't work. It goes to a 404 page when clicking through to the other pages e.g. 2, 3, 4. What is it I am missing?
global $query_string;
$myquery = wp_parse_args($query_string);
$myquery = array(
'paged' => $paged,
'numberposts'=>-1,
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'terms' => array('adventure'),
'field' => 'slug',
),
array(
'taxonomy' => 'holiday-types',
'terms' => array('adventure'),
'field' => 'slug',
),
),
);
query_posts($myquery);
while ( have_posts() ) : the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
// Reset Query
wp_pagenavi();
wp_reset_query();
$the_query
obj byvar_dump($the_query->request)