Custom query with tax_query not working

Home Forums Calendar Products Events Calendar PRO Custom query with tax_query not working

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1048310
    tpsonline
    Participant

    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;
    }
    #1049168
    George
    Participant

    Sorry @tpsonline, we cannot help with custom coding here 🙁 Please see the “Product Support” section of our terms and conditions for more information → http://theeventscalendar.com/terms

    I will close up this thread for now with these facts in mind.

    Best of luck with your project,
    George

    PS

    Before closing this thread, I looked at your code and it seems like the problem is that you’re referencing “TribeEvents::TAXONOMY”.

    TribeEvents is no longer a valid class name. Using Tribe__Events__Main::TAXONOMY instead may help here.

    Cheers!

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Custom query with tax_query not working’ is closed to new replies.