Skip to content

Instantly share code, notes, and snippets.

@bordoni
Created February 24, 2015 13:13
Show Gist options
  • Save bordoni/c9af7cdced204155a6e7 to your computer and use it in GitHub Desktop.
Save bordoni/c9af7cdced204155a6e7 to your computer and use it in GitHub Desktop.
Ignore past Events on Previous button
<?php
add_filters( 'tribe_has_previous_event', 'tec_forum_944441', 11 )
function tec_forum_944441( $has_previous ){
global $wp_query;
$has_previous = false;
$past = tribe_is_past();
$upcoming = ! $past;
$cur_page = (int) $wp_query->get( 'paged' );
$max_pages = (int) $wp_query->max_num_pages;
$page_1 = 0 === $cur_page || 1 === $cur_page;
// Simple tests based on pagination properties
if ( $upcoming && $cur_page > 1 ) $has_previous = true;
if ( $past && $cur_page < $max_pages ) $has_previous = true;
return $has_previous;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment