I am trying to query events by category, but when I add a tax_query to my query args, it stops working. I’ve verified that the categories have events in them. What might be the issue?
//Generates the boxes in the main nav menu with
function ac_flyoutBoxes($itemID) {
if (!$itemID) {
return false;
}
if (!is_int($itemID)) {
$itemID = intval($itemID);
//echo $itemID.'<br />';
}
//Query for events in this particular term
$args = array(
'post_type' => Tribe__Events__Main::POSTTYPE,
'tax_query' => array(
array(
'taxonomy' => TribeEvents::TAXONOMY,
'field' => 'term_id',
'terms' => array($itemID),
),
),
'meta_key'=>'_EventStartDate',
'orderby'=>'meta_value',
'order'=>'DESC',
'posts_per_page' => 5,
);
$the_query = new WP_Query( $args );
$output = '';
$output .= '<div class="flyoutBoxes">';
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
$output .= '<div class="flyoutBox">'.get_the_title().'</div>';
}
} else {
$output .= '<div class="flyoutBox">No events found!</div>';
}
$output .= '</div>';
wp_reset_postdata();
return $output;
}