Rocaboca
Rocaboca

Reputation: 107

Wordpress Infinite scroll never stops loading (doesn't force 404)

Okay, so I've gotten the infinite scroll plugin for Wordpress to work almost perfectly. The exception is that when the plugin tries to load a page that doesn't have any more posts (e.g. my-site/page/4/) it appends the posts from the initial page instead of returning a 404 page and thus kill infinite scroll. This results in the plugin never stopping loading posts.

I found the paged_404_fix() in the php file and changed it like this:

function paged_404_fix( ) {
  global $wp_query; 

  // I Have no idea why this worked, but it did, but for some reason it removed 
  // the strict doctype from the html and made the plugin act weird.
  echo count($wp_query->posts);

  if ( is_404() || !is_paged() || 0 != count( $wp_query->posts ) ){
      return;
  }

  $wp_query->set_404();
  status_header( 404 );
  nocache_headers();
}

The page that contains my posts is the "Posts page" pointing to a custom page.

I dont know if this is of any use but if I go to my-site/page/4 in the address bar I get redirected to my-site/ but if i go to my-site/page/random-string I get a 404.

Im suspecting that paged_404_fix() is fetching posts from the start page because my-site/page/4/ redirects to the start page.

Anyone had a similar problem with this plugin?

Upvotes: 0

Views: 799

Answers (1)

Rocaboca
Rocaboca

Reputation: 107

Apparently it had to do with the "Wordpress SEO by Yoast" plugins new update:

-Redirect paginated archive pages with a pagination number that doesn't exist to the first page of that archive.

This was the reason infinite scroll never stopped loading posts.

For more info: http://wordpress.org/support/topic/enhancement-in-update-messes-up-infinite-scroll-plugin

Upvotes: 2

Related Questions