Last active
May 7, 2019 15:13
-
-
Save jentheo/4e660ecd9a96d2991b5b6a816af3e872 to your computer and use it in GitHub Desktop.
Next day event link
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 | |
$current_day = tribe_get_start_date( null, false, 'Y-m-d' ); | |
$next_day = date( 'Y-m-d', strtotime( $current_day. ' + 1 days' ) ); | |
$day_after = date( 'Y-m-d', strtotime( $next_day. ' + 1 days' ) ); | |
$prev_day = date( 'Y-m-d', strtotime( $current_day. ' - 1 days' ) ); | |
$current_event_categories = get_the_terms( $post, 'tribe_events_cat' ); | |
for ( $i = 0; $i < count( $current_event_categories ); $i++ ) { | |
$current_event_category = $current_event_categories[ $i ]->slug; | |
} | |
$next_day_event = tribe_get_events( array( | |
'start_date' => $next_day, | |
'posts_per_page' => 1, | |
'end_date' => $day_after, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'tribe_events_cat', | |
'field' => 'slug', | |
'terms' => $current_event_category, | |
), | |
), | |
) ); | |
// error_log(print_r($next_day_event, true)); /* if this is in use, it prints an empty array */ | |
for ( $i = 0; $i < count( $next_day_event ); $i++ ) { | |
$start_date = get_post_meta( $next_day_event[ $i ]->ID, '_EventStartDate', true ); | |
if ( date( 'Y-m-d', strtotime( $start_date ) ) == $next_day ) | |
$link_to_next_day = $next_day_event[ $i ]->guid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment