I have a WP query that searches for any custom posts under type 'tribe_events' tagged as 'featured' under the taxonomy 'tribe_events_cat'.
So, just to be clear:
post_type = 'tribe_events'
taxonomy = 'tribe_events_cat'
terms = 'featured', 'streamteam'
However, it returns nothing when outside of page ID 199. I can comment-out the tax_query and it works but returns all posts, not just ones tagged as 'featured'.
if(is_page(199)) {
$tribe_events_cat = array( 'featured','streamteam' );
} else {
$tribe_events_cat = 'featured';
}
// The Query
$event_args = array (
'post_type' => 'tribe_events',
'posts_per_page' => 1,
'tax_query' => array (
array (
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => $tribe_events_cat,
),
),
'meta_query' => array(
array(
'key' => '_EventStartDate',
'value' => date("Y-m-d"),
'compare' => '>=',
'type' => 'DATE',
),
),
'meta_key' => '_EventStartDate',
'order' => 'ASC'
);
$event_query = new WP_Query( $event_args );
// The Loop
if ( $event_query->have_posts() ) {
while ( $event_query->have_posts() ) {
$event_query->the_post();
?>
POST CONTENT HERE
<?php
}
}
What's wrong with my tax_query?!
EDIT:
This answer solved my initial problem of no posts being returned from my query
https://stackoverflow.com/questions/30213495/wp-query-returns-no-results
Apparently there was a filter conflicting with my query.
However, I'm still having an issue.. I only want to return posts with both 'featured' AND 'streamteam' terms when on page ID 199. Right now it's returning posts that only belong to the 'featured' term.
taxonomy = 'tribe_events-cat'
, in the query it istribe_events_cat
, is that just a typo?