Skip to content

Instantly share code, notes, and snippets.

@mrwweb
Last active November 13, 2024 16:44
Show Gist options
  • Save mrwweb/705a1593657ea647aaa0 to your computer and use it in GitHub Desktop.
Save mrwweb/705a1593657ea647aaa0 to your computer and use it in GitHub Desktop.
Get Upcoming Events with tribe_get_events()
<?php $proj_events = tribe_get_events( array(
'posts_per_page' => 3,
'eventDisplay' => 'list' // only upcoming
), true ); ?>
<?php if( $proj_events->have_posts() ) :
?>
<div class="project-related__block project-related__block--events">
<h3>Events</h3>
<ul class="bulletless-list">
<?php while( $proj_events->have_posts() ) : $proj_events->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span class="entry-meta"><?php echo tribe_get_start_date( null, true, 'g:ia, F j' ); ?></span></li>
<?php endwhile; ?>
</ul>
</div>
<?php else: ?>
<p>There are currently no upcoming events for <?php the_title(); ?>.</p>
</div>
<?php endif; wp_reset_postdata(); ?>
<?php endif;
@alexandre-kakal
Copy link

alexandre-kakal commented Nov 13, 2024

https://theeventscalendar.com/knowledgebase/using-tribe_get_events/

// Retrieve the next 5 upcoming events
$events = tribe_get_events( [
   'posts_per_page' => 5,
   'start_date'     => 'now',
] );

or :
tribe_get_events(array('ends_after' => 'now'));

depends on your needs

gl hf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment