JetPack infinite scroll shows older post button when there is no more posts

I’ve setup infinite scroll in my WordPress theme. I’ve set it up as ‘click’ so that the user has to click to load more posts. I’ve setup 2 post per page and I have 4 posts total.

add_theme_support( 'infinite-scroll', array(
    'type'           => 'click',
    'container'      => 'news-wrap',
    'footer'         => 'false',
    'footer_widgets' => 'false',
    'posts_per_page' => 2
) );

The issue is that the “Older post” button appears even when there is no more posts to be loaded. So the initial page loads, I see two posts and the button. Click the button, two more post load and the button still appears even though all 4 posts are now loaded. You click again, the plugin attempts to load more posts (there isn’t) and then disappears. Obviously there is no reason for the button to appear after the second load.

Related posts

Leave a Reply