Skip to content

Instantly share code, notes, and snippets.

@ckpicker
Created August 6, 2012 20:02
Show Gist options
  • Save ckpicker/3278002 to your computer and use it in GitHub Desktop.
Save ckpicker/3278002 to your computer and use it in GitHub Desktop.
EC Pro Redirect
<?php
//Query Events and get next upcoming
$postslist = query_posts('order=DESC&orderby=modified&posts_per_page=1&post_type=tribe_events&eventDisplay=upcoming');
if(!empty($postslist)) {
//Grab Start date from next upcoming event and use /YYYY-MM/ in events URL
$eventStartDate = strtotime($postslist[0]->EventStartDate)
$nextUpcomingLink = tribe_get_events_link() . date('Y-m', $eventStartDate) . '/';
} else {
$nextUpcomingLink = tribe_get_events_link();
}
wp_reset_query();
?>
<div id='tribe-events-calendar-header' class="clearfix">
<span class='tribe-events-calendar-buttons'>
<a class='tribe-events-button-on' href='<?php echo tribe_get_listview_link(); ?>'><?php _e('Event List', 'tribe-events-calendar')?></a>
<a class='tribe-events-button-off' href='<?php echo $nextUpcomingLink; ?>'><?php _e('Calendar', 'tribe-events-calendar')?></a>
</span>
</div><!--tribe-events-calendar-header-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment