Hi, I'm using Jetpack's Infinite Scroll on a custom theme and it's working in general but I'm having a problem with the posts_per_page
argument.
Here's my setup code:
function mytheme_render_infinite_scroll() {
// loading different content templates depending on what type of page is being viewed
while ( have_posts() ) : the_post();
if ('mytheme_portfolio' == get_post_type() && !is_search()) :
get_template_part( 'content', 'archive-portfolio' );
elseif ( is_search() ) :
get_template_part('content','search');
else :
get_template_part( 'content', get_post_format() );
endif;
endwhile;
}
function mytheme_jetpack_setup() {
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer_widgets' => 'footer-widgets',
'type' => 'click',
'render' => 'mytheme_render_infinite_scroll',
'wrapper' => true,
'posts_per_page' => 10
) );
}
add_action( 'after_setup_theme', 'mytheme_jetpack_setup' );
As you can see I'm using 'type' => 'click'
and have a custom function for render
which gets different templates depending on what post-type is being viewed or whether search is being viewed. That is all working fine though.
Basically the problem is the 'posts_per_page' => 10
line is not having any effect. The number of posts showing on my pages relates to the number set for the "Blog pages show at most X posts" setting in Settings -> Reading in the WP admin panel, which is currently set to 5, not the 10 that I want.
I've tried looking here http://jetpack.me/support/infinite-scroll/ but couldn't find anything to help.
I'm not sure if it's worth noting but I have a message in Settings -> Reading which says:
"To infinity and beyond...We've disabled this option for you since you have footer widgets in Appearance → Widgets, or because your theme does not support infinite scroll."
I thought this probably wasn't relevant though, as I said the infinite scroll is working for me but with 'type' => 'click'
, I think the above message has something to do with that.
I have deactivated all other plugins and also tried this in Twenty Thirteen theme, I get the same problem in that too.
I'm using Jetpack 2.7.