Question

Problem: Unable to change number of posts on Jetpack Infinite Scroll

Desired Result: Load 10 posts per infinite scroll instead of default 7

Theme: Twenty Fifteen (Child)

Tried:

1) Looking for a setting in Jetpack Infinite Scroll menu - nothing there

2) Adding this code to child functions.php

function twenty_fifteen_infinite_scroll_init() {
    add_theme_support( 'infinite-scroll', array(
       'posts_per_page' => 10,
    ) );
}
add_action( 'after_setup_theme', 'twenty_fifteen_infinite_scroll_init' );
Was it helpful?

Solution

Found the code that works here:

https://themeshaper.com/2013/10/08/how-to-override-jetpack-infinite-scroll-settings-in-a-child-theme/

 /*
 * Change the posts_per_page Infinite Scroll setting from 10 to 20
 */
function my_theme_infinite_scroll_settings( $args ) {
    if ( is_array( $args ) )
        $args['posts_per_page'] = 20;
    return $args;
}
add_filter( 'infinite_scroll_settings', 'my_theme_infinite_scroll_settings' );
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top