Infinite scroll activated but not working
-
Hi,
I activated the infinite scroll module in Jetpack, but it doesn’t seem to work:
http://www.detection-du-mensonge.com/blog/
Any idea how to fix this?
Thanks!
-
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.phpin 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 apost-loop.phpfile. 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 inindex.phpand refer topost-loop.phpinstead.That should do it.
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 intofunctions.phpdirectly (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 thepost-loop.phpin 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.phpfile 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 (http://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 theview sourceor similar command in your browser to see what div the posts are thrown into and add that div name to thecontainervalue of the first code block above.@othello You can also follow the instructions here to set up Infinite Scroll:
http://jetpack.me/support/infinite-scroll/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:
http://ottopress.com/2012/jetpack-and-the-infinite-scroll/
The topic ‘Infinite scroll activated but not working’ is closed to new replies.