Skip to content

Instantly share code, notes, and snippets.

@brichards
Created May 22, 2016 01:33
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 brichards/6978a39d5643dacdb5249527a050ff45 to your computer and use it in GitHub Desktop.
Save brichards/6978a39d5643dacdb5249527a050ff45 to your computer and use it in GitHub Desktop.
Filter JetPack infinite scroll type based on template
<?php
/**
* Ensure that JetPack uses "click" for infinite scroll
* on the front page, regardless of all other settings.
*
* We need to filter the JS settings because all other
* means of controling scroll vs click are initiated
* before the template conditionals know which page
* we're viewing.
*
* @param array $settings JetPack Infinite Scroll settings.
* @return array Modified settings.
*/
function rzen_infinite_scroll_js_settings( $settings = array() ) {
if ( is_front_page() ) {
$settings['type'] = 'click';
}
return $settings;
}
add_filter( 'infinite_scroll_js_settings', 'rzen_infinite_scroll_js_settings' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment