Jetpack Infinite Scroll - changing number of posts
-
27-01-2021 - |
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' );
La solution
Found the code that works here:
/*
* 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' );
Licencié sous: CC-BY-SA avec attribution
Non affilié à wordpress.stackexchange