JetPack Infinite Scroll not working on custom theme

I have a custom theme where I’ve tried to integrate the Infinite Scroll option within JetPack. Per this article, I’ve added the following code to functions.php (in addition to activating the module) –

<?php 
    add_theme_support( 'infinite-scroll', array(         
    'container' => 'content',         
    'footer' => 'page',       
) );
?>

The live site can be found here.

Read More

My problem is that the infinite scroll function doesn’t seem to be, well, functioning. Pagination still occurs when 10 posts are reached.

I’m not exactly sure where I’ve gone wrong as I followed the articles steps as they were written. Any ideas?

Related posts

2 comments

  1. Have you tried adding 'type' => 'click' under 'footer' => 'page', to see if the Jetpack works with click rather than the default scroll?

    It is also worth going to Settings -> Reading in the admin panel… does it say “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.”? You might look at what it says here before trying the above step. If you get this error it might be a conflict between your footer and the scroll.

    I think your container might also need to be 'blog' and not 'content', as the div your posts are held in seems to be #blog.

  2. For those of you having trouble with this, it is because there is no render function. Add the following to your functions.php file:

    add_theme_support( 'infinite-scroll', array(
        'container'      => 'blogroll', 
        'footer'         => false,
        'posts_per_page' => 1,
        'type'           => 'click',
        'render'         => 'wb_infinite_scroll_render',
    ) );
    
    function wb_infinite_scroll_render() {
        get_template_part( 'templates/content-post', 'standard' );
    }
    

    Change the name of the container to the name of the container you want the posts to populate in.

    Also — I have a folder named “templates” in my theme with a content-post-standard.php file within there that allows me to print out everything I need.

    Hope this helps!

Comments are closed.