Infinite Scroll with roots/sage (slimjetpack)

Anyone have infinite scrolling working with sage? I can get it working on every regular wordpress twenty* theme but not a basic sage theme.

I’ve modified the settings, changed the render to a custom page/function but it doesn’t seem to want to load in any additional pages.

I’ve also tried the other wordpress plugins which also don’t work with sage when doing the recommended changes for custom themes.

I’ve spent over 8 hours googling and researching but there’s no answers and no solutions.

Are there any JavaScript errors in your console? PHP isn’t throwing any warnings/errors ?

I’m not sure what Sage would be doing to “break” all infinite scrolls. The only thing I could think that it might be is if the plugin is throwing out jQuery calls inline with the plugin and not at wp_footer(), so it’s possible jQuery calls are being made before jQuery has loaded. But you should see an error in your console if that’s the case.

When I’ve used infinite scroll in the past, I’ve used the popular infinite scroll script directly, installing it with Bower

1 Like

No errors at all. All “appears” to work but no results are fetched. (the get_template_part is seemingly what’s not working)

Same goes for the infinite-scroll plugin from wordpress; setup all as instructed and doesn’t work.

As soon as I install a non-sage theme it works perfect.

Here’s what I’m using:

"wpackagist-plugin/slimjetpack": "2.7.0.1"

Default render doesn’t seem to work, nor does any custom ones i’ve tried (even took loop.php and other template files from other themes to try and get it to work). Here’s the basics:

function infinite_scroll_render() {
  while (have_posts()) : the_post();
    get_template_part('templates/content', get_post_type() != 'post' ? get_post_type() : get_post_format());
    //get_template_part('templates/content');
  endwhile;
}

function infinite_scroll_init() {
  add_theme_support( 'infinite-scroll', array( 
      'type'           => 'scroll',
      'footer'         => false,
      'footer_widgets' => false,
      'container'      => 'posts-container',
      'wrapper'        => true,
      'render'         => 'infinite_scroll_render',
      'posts_per_page' => false,
  ) );
}
add_action( 'init', __NAMESPACE__ . '\\infinite_scroll_init' );

The only other thing I can think of is it’s expecting a certain HTML/CSS syntax in the posts (or maybe missing the paged param?)

You’re passing the name of the function in render without the namespace

2 Likes

oh shit snacks. there’s a facepalm.

thx bro