Roots Sage with Jetpack Infinite Scroll

This is how I got it working on one recent site. I had to use the “render” callback function to iterate through the loop and use sage (9) template function. I hope it helps you figure it out!

    // Add support for Jetpack's Infinite Scroll
    add_theme_support('infinite-scroll', [
        'container' => 'main',
        'footer' => false,
        'type' => 'scroll',
        'wrapper' => false,
        'posts_per_page' => 12,
        'render' => __NAMESPACE__ . '\\infinite_scroll',
    ]);

    function infinite_scroll()
    {
        echo '<div class="container-inner">';

        while (have_posts()) : the_post();
            echo template('partials.content-' . get_post_type());
        endwhile;

        echo '</div>';
    }
2 Likes