• Resolved sarahessex

    (@sarahessex)


    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.

    http://wordpress.org/plugins/jetpack/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter sarahessex

    (@sarahessex)

    I just tried this on a completely fresh install of WP with a fresh DB using Twenty Twelve, with no other plugins active, and the posts_per_page line is still having no effect. It’s still taking the number of posts from Blog pages show at most __ posts in Settings -> Reading.

    Settings used this time:

    add_theme_support( 'infinite-scroll', array(
    	'type' => 'click',
    	'container' => 'content',
        'footer' => 'page',
    	'posts_per_page' => false,
    ) );

    Thread Starter sarahessex

    (@sarahessex)

    I’ve done some testing on this, am I right in thinking the posts_per_page argument only works if type is scroll and not click?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    am I right in thinking the posts_per_page argument only works if type is scroll and not click?

    That’s correct. If you use click, you’ll want to change the number of posts to be displayed under Settings > Reading in your dashboard.

    Thread Starter sarahessex

    (@sarahessex)

    Thanks for confirming 🙂

    Please add this to the documentation – I have been scratching my head over this one!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘posts_per_page not having any effect’ is closed to new replies.