Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Othello

    (@othello)

    I guess this is linked to my theme, but I have no idea what to look for..?

    Yes, the theme must be modified to support Jetpack Infinite Scroll. Here is the minimum that must be done:

    1. Add the following to functions.php in your theme directory:

    // theme support for Jetpack infinite scroll
    add_theme_support( 'infinite-scroll', array(
    	'container'  => 'content',
    	'render'    => 'infinite_scroll_render',
    	'footer' => 'footer'
    ) );

    In “container” you put the div name that the main content of your site renders into, this is usually “content” but may be something different.

    // render function for Jetpack infinite scroll that 2010 uses, the later WP themes don't need this
    function infinite_scroll_render() {
    	get_template_part( 'post-loop' );
    }

    2. Put the code that renders a single post on the main page of your site (from index.php) into a post-loop.php file. The first line should be something like <?php while (have_posts()) : the_post(); ?> and the last line something like <?php endwhile; ?>.
    3. Optional, but delete that code that renders a single post in index.php and refer to post-loop.php instead.

    That should do it.

    Thread Starter Othello

    (@othello)

    Oups, I did everything you said but it didn’t seem to work.

    Are you sure the second block code goes into the index.php and not blog.php file?

    Do you think you could have a look at my blog and tell me what to change? (www.detection-du-mensonge.com/blog)

    Thank you!

    Unfortunately a site URL is nearly useless when only filesystem-level access provides the ability to see the PHP code. What is blog.php, there should usually be no such file in a WordPress theme. The first two blocks of code I put above go into functions.php directly (not within any functions currently in the file).

    You don’t put that second block of code straight into the index.php, you just put the line that refers to the post-loop.php in alone, something like this:

    <?php if (have_posts()) :
    		// loop to get posts from the database and display them
    		get_template_part( 'post-loop' );
    		?>

    Remember that the contents currently between that if loop have been cut out and are the only contents of the post-loop.php file you just created. You don’t have to do this last step, but doing it means you only have one place where the code to render posts resides which helps in later changes and debugging you may deal with.

    I’ve been describing the way it is set up, and working, on my blog (https://alex.clst.org/dbd), so the code I’ve shared with you does work when implemented properly. Perhaps the div your posts render in isn’t content, that may also screw things up. Look using the view source or similar command in your browser to see what div the posts are thrown into and add that div name to the container value of the first code block above.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    @othello You can also follow the instructions here to set up Infinite Scroll:
    https://jetpack.me/support/infinite-scroll/

    Thread Starter Othello

    (@othello)

    @alexdbd: thanks, unfortunately I couldn’t get it to work
    @jeremy Herve: I had tried it before posting here ??

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    You can also have a look at this post: it’s a great tutorial, and it should help you understand what you need to change for IS to work:
    https://ottopress.com/2012/jetpack-and-the-infinite-scroll/

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Infinite scroll activated but not working’ is closed to new replies.