Skip to content

Instantly share code, notes, and snippets.

@mrwweb
Last active September 28, 2022 16:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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;
@NanyThery
Copy link

Thanks a lot, your code helped me a lot with a php theme I had to modify in Wordpress :)

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