0

I have carefully followed the instructions at OttoPress, and read all the documentation at Jetpack.me. I feel like I understand what should work, but for some reason Infinite Scroll is not firing.

I have installed Jetpack onto my Wordpress installation and disabled all features apart from Infinite Scroll.

enter image description here

I created a content.php, as per the recommendations at OttoPress, and my page (page-news.php) loads that content just fine, and as I'd expect. The code looks like this:

<div id="masonry">
  <?php while (have_posts()) : the_post(); 
    get_template_part( 'content', get_post_format() );                                      
  endwhile; ?>
</div>

With that all working correctly, I then added the following to functions.php:

function bones_infinite_loop_init(){
  add_theme_support( 'infinite-scroll', array(
    'footer'         => false,
    'type'           => 'scroll',
    'footer_widgets' => false,
    'container'      => 'masonry',
    'wrapper'        => false,
    'posts_per_page' => false
  ));
}
add_action( 'init', 'bones_infinite_loop_init' );

When that didn't work, I even tried adding:

'render'         => 'bones_infinite_scroll_render',

And created a function with the post formatting in it.

I've also tried:

'type'           => 'click'

But nothing appears on the page, no extra posts are loaded when I scroll to the end of the page, and infinite-scroll does not appear as a class on the body element.

The are also no errors in the developer console. There are no errors when I set WP_DEBUG to true. I've also tried disabling all other plugins.

What am I missing?

I'm wondering if it's to do with any of the following:

  1. I'm trying infinitely scroll Custom Posts
  2. On page-news.php I have 'posts_per_page' => 3 and maybe that's conflicting somehow?
  3. I've missed a crucial (but obvious) step in setting things up

Thanks for any help.

4
  • Are you using some sort of Javascript Masonry? And if you just use the default instructions for Jetpack, it still doesn't work? jetpack.me/support/infinite-scroll
    – RachieVee
    Commented Oct 29, 2014 at 19:16
  • @RachieVee Yes, I'm using MasonryJS. And yes, I've followed the documentation at jackpack.me Commented Oct 29, 2014 at 19:19
  • I had an issue getting Jetpack to work with Masonry - have you tried disabling masonry just to see if Jetpack works?
    – RachieVee
    Commented Oct 29, 2014 at 19:21
  • @RachieVee Thanks, just tried that. No change. I'm sure I've missed something really obvious. Commented Oct 29, 2014 at 19:26

1 Answer 1

1

I'm assuming you want it to do what happens on Jetpacks' example without a button, just scroll down and more posts appear until there's no more?

Not sure if this will help, but your code has the wrapper parameter set to false while Jetpack's example where they have the footer parameter section has it set to true:

add_theme_support( 'infinite-scroll', array(
    'type'           => 'scroll',
    'footer_widgets' => false,
    'container'      => 'content',
    'wrapper'        => true, //This is true whereas your example is false
    'render'         => false,
    'posts_per_page' => false,
) );

You can also try running the add_theme_support function outside of the action hook you're using and seeing if anything happens.

Also, I would try disabling Jetpack and in page-news.php, confirm that there is default pagination going on. If not, then troubleshoot the pagination if it's non-existent because it's possible that it's messing with Jetpack. Infinite scroll needs WordPress' default pagination to exist I believe because it breaks each section of posts by their "pages".

I'd say if there are no console errors in your browser, or PHP errors when you set your wp-config's debug to true - then you may have to seek more advanced help or maybe even provide a link to the site for deeper investigation. Good luck!

1
  • I set the debug to true, but still no errors. I tried setting wrapper to true, and no change. I'll look into the pagination. Thanks. Commented Oct 30, 2014 at 14:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.