Skip to content

Commit

Permalink
Infinite Scroll: Don't clobber the posts_per_page option if provided
Browse files Browse the repository at this point in the history
Infinite Scroll currently clobbers any passed-in value for posts_per_page if the type is set to click.
This commit changes the behavior to match the documentation:
https://jetpack.me/support/infinite-scroll/

Merges #2808
Props codebykat

https://[private link]

Merges r132547-wpcom.
  • Loading branch information
jeherve authored and georgestephanis committed Feb 1, 2017
1 parent 9dde6c7 commit 5303a06
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions modules/infinite-scroll/infinity.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,15 @@ static function get_settings() {
$settings['type'] = 'click';
}

// Ignore posts_per_page theme setting for [click] type
if ( 'click' == $settings['type'] )
$settings['posts_per_page'] = (int) get_option( 'posts_per_page' );

// Backwards compatibility for posts_per_page setting
elseif ( false === $settings['posts_per_page'] )
$settings['posts_per_page'] = 7;
// posts_per_page defaults to 7 for scroll, posts_per_page option for click
if ( false === $settings['posts_per_page'] ) {
if ( 'scroll' === $settings['type'] ) {
$settings['posts_per_page'] = 7;
}
else {
$settings['posts_per_page'] = (int) get_option( 'posts_per_page' );
}
}

// Force display of the click handler and attendant bits when the type isn't `click`
if ( 'click' !== $settings['type'] ) {
Expand Down

0 comments on commit 5303a06

Please sign in to comment.