Filter JetPack infinite scroll type based on template
This file contains 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
<?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