Skip to content

Instantly share code, notes, and snippets.

@trishasalas
Last active April 14, 2017 05:21
Show Gist options
  • Save trishasalas/1ebb4428f59a6873af22af176f7bee79 to your computer and use it in GitHub Desktop.
Save trishasalas/1ebb4428f59a6873af22af176f7bee79 to your computer and use it in GitHub Desktop.
For The Events Calendar: Gets the post object for the next event when called from 'single-event.php'
<?php
/**
* Gets the post object for the next event when called from 'single-event.php'
*
*/
$start_date = get_post_meta( get_the_ID(), '_EventStartDate', true );
$args = array(
'post__not_in' => array( get_the_ID() ),
'posts_per_page' => 1,
'meta_query' => array(
array(
'key' => '_EventStartDate',
'value' => $start_date,
'type' => 'DATETIME',
'compare' => '>',
),
array(
'key' => '_EventHideFromUpcoming',
'compare' => 'NOT EXISTS',
),
'relation' => 'AND',
),
);
$events = tribe_get_events( $args );
foreach ( $events as $event ) {
/**
* Display the Event Data
*/
?>
<h4><a href="<?php the_permalink();?>"><?php echo $event->post_title;?></a></h4>
<p><?php echo $event->EventStartDate;?> to <?php echo $event->EventEndDate;?></p>
<?php echo get_the_post_thumbnail( $event->ID );?>
<?php
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment