Last active
August 29, 2015 14:01
-
-
Save halfempty/a99abf2c883d88333380 to your computer and use it in GitHub Desktop.
Non-AJAX Previous Events / Next Events Links for WP Events Calendar Pro
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
function spellerberg_get_next_events_link() { | |
global $wp_query; | |
$nextlink = ''; | |
$paged = get_query_var( 'paged' ); | |
if ( tribe_is_past() ) : | |
if ( $paged > 2 ) : | |
$nextpagenumber = $paged - 1; | |
$nextlink = tribe_get_past_link() . '?action=tribe_list&tribe_paged=' . $nextpagenumber; | |
elseif ( $paged == 2 ) : | |
$nextlink = tribe_get_past_link(); | |
else : | |
$nextlink = tribe_get_upcoming_link(); | |
endif; | |
else : // Is Upcoming | |
if ( get_next_posts_link() ) : // There are subsequent pages in the Upcoming list | |
if ( $paged < 2 ) : | |
$nextlink = tribe_get_upcoming_link() . '?action=tribe_list&tribe_paged=2'; | |
else : | |
$prevpagenumber = $paged + 1; | |
$nextlink = tribe_get_upcoming_link() . '?action=tribe_list&tribe_paged=' . $prevpagenumber; | |
endif; | |
endif; | |
endif; | |
if ( $nextlink != '' ) return $nextlink; | |
} | |
function spellerberg_get_previous_events_link() { | |
global $wp_query; | |
$prevlink = ''; | |
$paged = get_query_var( 'paged' ); | |
if ( tribe_is_upcoming() ) : | |
if ( $paged > 2 ) : | |
$prevpagenumber = $paged - 1; | |
$prevlink = tribe_get_upcoming_link() . '?action=tribe_list&tribe_paged=' . $prevpagenumber; | |
elseif ( $paged == 2 ) : | |
$prevlink = tribe_get_upcoming_link(); | |
else : | |
$prevlink = tribe_get_past_link(); | |
endif; | |
else : // Is Past | |
if ( get_next_posts_link() ) : // There are subsequent pages in the Past list | |
if ( $paged < 2 ) : | |
$prevlink = tribe_get_past_link() . '?action=tribe_list&tribe_paged=2'; | |
else : | |
$prevpagenumber = $paged + 1; | |
$prevlink = tribe_get_past_link() . '?action=tribe_list&tribe_paged=' . $prevpagenumber; | |
endif; | |
endif; | |
endif; | |
if ( $prevlink != '' ) return $prevlink; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment