Skip to content

Instantly share code, notes, and snippets.

@elimn
Last active June 12, 2018 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elimn/308b6a6a6259d4ac3b6b to your computer and use it in GitHub Desktop.
Save elimn/308b6a6a6259d4ac3b6b to your computer and use it in GitHub Desktop.
MT | TEC | Prevent Next/Prev pages from being loaded via Ajax in List and Month views
<?php
/*
* Prevents Next/Prev pages from being loaded via Ajax in List and Month views
*/
function tribe_prevent_ajax_paging() {
echo "
<script>
jQuery(document).ready(function(){
// Tribe Bar
jQuery( 'form#tribe-bar-form' ).off( 'submit' );
jQuery( '#tribe-events' )
.off( 'click', '.tribe-events-nav-previous, .tribe-events-nav-next' ) // Month and Week View
.off( 'click', '.tribe-events-nav-previous a, .tribe-events-nav-next a') // Day View
.off( 'click', '#tribe-events-footer .tribe-events-nav-previous a, #tribe-events-footer .tribe-events-nav-next a' ); // Day View
// Month View
jQuery( 'body' ).off( 'click', '#tribe-events-footer .tribe-events-nav-previous, #tribe-events-footer .tribe-events-nav-next' );
// List View
jQuery( '#tribe-events-content-wrapper' )
.off( 'click', 'ul.tribe-events-sub-nav a[rel=\"next\"]' )
.off( 'click', 'ul.tribe-events-sub-nav a[rel=\"prev\"]' )
.off( 'click', '#tribe-events-footer .tribe-events-nav-previous a, #tribe-events-footer .tribe-events-nav-next a' );
/* This breaks map and Photo view as of v4.0, because their nonJS href='#'
// Map and Photo View
jQuery( '#tribe-events' )
.off( 'click', 'li.tribe-events-nav-next a')
.off( 'click', 'li.tribe-events-nav-previous a');
*/
});
</script>";
}
add_action( 'wp_footer', 'tribe_prevent_ajax_paging', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment