Tune Jetpack Infinite Scroll
Sets how many posts Jetpack's Infinite Scroll loads at a time and switches it to a "Load more" button, which is friendlier to footers and keyboard users than endless scrolling.
Opens WPIDE on
Code
$wpide_posts = 9; // Posts per load.
$wpide_type = 'click'; // click = "Load more" button, scroll = automatic.
add_filter( 'infinite_scroll_settings', function ( $settings ) use ( $wpide_posts, $wpide_type ) {
if ( is_array( $settings ) ) {
$settings['posts_per_page'] = max( 1, (int) $wpide_posts );
$settings['type'] = 'scroll' === $wpide_type ? 'scroll' : 'click';
}
return $settings;
} );
Notes
Your theme must support Infinite Scroll. Set $wpide_type to scroll to keep automatic loading.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.