Skip to content

Instantly share code, notes, and snippets.

@logoscreative
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save logoscreative/94bb1d29b2a4df2750c5 to your computer and use it in GitHub Desktop.
Save logoscreative/94bb1d29b2a4df2750c5 to your computer and use it in GitHub Desktop.
Redirecting to Next Recurring Event Instance
if( !empty($get_recurrence_event->posts) && tribe_is_recurring_event($get_recurrence_event->posts[0]->ID) && get_post_status($get_recurrence_event->posts[0]) == 'publish' ){
$nextevent = '';
$now = strtotime('now');
foreach ( tribe_get_recurrence_start_dates($event->ID) as $eventinstance ) {
$upcoming = strtotime($eventinstance);
if ( $now < $upcoming ) {
$eventinstance = explode(" ", $eventinstance);
$nextevent = $eventinstance[0];
break;
}
}
if ( $nextevent ) {
$current_url = str_replace( 'all', $nextevent, TribeEvents::instance()->getLink('all', $get_recurrence_event->posts[0]->ID));
} else {
$current_url = TribeEvents::instance()->getLink('all', $get_recurrence_event->posts[0]->ID);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment