Support

Account

Home Forums ACF PRO Tribe Events Taxonomy query

Solved

Tribe Events Taxonomy query

  • I created a page template that queries events from a category (tribe events plugin) Instead of replicating the template for every single page category, I would like to include a multi select checkbox so the template pulls in a query of whatever categories are checked off in the page settings.

    I set up the field called “category” but I am not sure how to incorporate it into my query

                 
    <?php 									
    					
    global $post;	
    $events = tribe_get_events(
            array(
                'eventDisplay'=>'upcoming',
                'posts_per_page'=>-1,
                'tax_query'=> array(
                    array(
                        'taxonomy' => 'tribe_events_cat',
                        'field' => 'slug',
                        'terms' => 'entertainment'
                    )
                )
       ) );
     ?>
    		
    		
    <div class="div-tiles" id="event-wrapper">	
    				
    <?php foreach ( $events as $post ) {
        setup_postdata( $post );  ?>
    
                
    <div class="tile-link w-inline-block">
     <div class="tile-link-content">
    <a href="<?php echo tribe_event_link(); ?>">
     <div class="div-tile-link-thumb">
     <?php echo get_the_post_thumbnail( $event->ID, 'full' );?>
                                                                                   
     </div> </a>
                                    
    <div class="datebox"> <img alt="decorative slant image" class="slant-img" src="<?php echo get_template_directory_uri(); ?>/images/slant-top.png">
                                        
                                    
    <div class="event-date"><?php echo tribe_get_start_date( $post->ID, false, 'F d' ); ?></div>
                                        
    <div class="slant-element"><img alt="decorative slant image" class="slant-img" src="<?php echo get_template_directory_uri(); ?>/images/slant-bottom.png">
     </div></div>
                                        
    <div class="tile-link-text">
    <a href="<?php echo tribe_event_link(); ?>" class="nodecoration"><h3 class=" less-top-margin link-title"><?php the_title(); ?></h3></a>
    <p><?php the_excerpt(); ?></p>
    <a class="btn" href="<?php echo tribe_event_link(); ?>"><div class="button with-left-margin with-top-margin">learn more</div></a>                                    <a class="btn purple" href="<?php echo tribe_get_event_meta( get_the_ID(), '_EventURL', true ); ?>" target="_blank"><div class="button with-left-margin with-top-margin">buy tickets</div><!--
    </a>
           </div>
         </div>
     </div>
                            
     <?php }  wp_reset_query(); ?>
    </div>  
  • Assuming your “category” field is a taxonomy field and the return type is term_id. then you can try:

    
    $events = tribe_get_events(
            array(
                'eventDisplay'=>'upcoming',
                'posts_per_page'=>-1,
                'tax_query'=> array(
                    array(
                        'taxonomy' => 'tribe_events_cat',
                        'field' => 'term_id',
                        'terms' => get_field('your_category_field_name')
                    )
                )
       ) );
    
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Tribe Events Taxonomy query’ is closed to new replies.