Last active
April 14, 2017 05:21
-
-
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'
This file contains 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 | |
/** | |
* 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