Jetpack infinite scroll not working on twentysixteen custom theme

I duplicated twentysixteen theme and only changed the name of the folder and the name of the theme in style.css. I then added in functions.php :

function twenty_sixteen_infinite_scroll_init() {
        add_theme_support( 'infinite-scroll', array(
            'container' = 'main',
            'type' = 'click',
            'posts_per_page' = '2',
        ) );
    }
    add_action( 'after_setup_theme', 'twenty_sixteen_infinite_scroll_init' );

The older posts button appears but after I click it no more posts are loading. What am I missing?

On the original twentysixteen the infinite scroll works well.

Topic theme-twenty-sixteen infinite-scroll plugin-jetpack Wordpress

Category Web


I added the render and this is the full code.

function mytheme_infinite_scroll_init() {
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'render' => 'mytheme_infinite_scroll_render',
'container'      => 'content',
'posts_per_page' => 2,
) );
}

function mytheme_infinite_scroll_render() {
while( have_posts() ) {
    the_post();
    get_template_part( 'template-parts/content', get_post_format() );
    }
}

add_action( 'init', 'mytheme_infinite_scroll_init' );

you may find a problem that the pagination is shown and you may solve it by removing it from the theme or give it style display:none

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.