Last active
November 13, 2024 16:44
-
-
Save mrwweb/705a1593657ea647aaa0 to your computer and use it in GitHub Desktop.
Get Upcoming Events with tribe_get_events()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
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
Thanks a lot, your code helped me a lot with a php theme I had to modify in Wordpress :)