Infinite scroll repeats initial posts
-
So I have tried to tackle this a couple of times and am just not having any luck. So right now I have archive pages set up so that when a user first visits the page, it will display the first three posts belonging to that archive. As they scroll down infinite scroll is supposed to kick in and then load 3 additional posts with each load. I also have a filter on the page so that users can filter posts by custom taxonomies, and then new posts load on the page using the same infinite scroll functionality.
So the problem is that although infinite scroll seems to be working fine for the filtered results, it is giving me problems on the initial page load. Initially the page shows the first three posts, however when scrolling down infinite scroll kicks in and then repeats the same first three posts. You can see and example here: http://projects.server291.com/nymj/category/clinical-article/
I am assuming there is something wrong with my code. Here it is relevant code. The only difference I can think of is that infinite scroll isn’t playing nice with the default query on the archive page. Just a though since it is working fine with the filter which is utilizing a custom WP_Query. Also, this is being used for a custom post type.
Infinite Scroll Functions
/** * Infinite scroll rendering */ function nymj_infinite_scroll() { // On issues archive // if( is_page_template( 'issues' ) ) { // } // Default archives if( is_archive() ) { while( have_posts() ) : the_post(); include( locate_template( 'templates/article-snippet.php' ) ); endwhile; } } /** * Infinite scroll functionality */ add_theme_support( 'infinite-scroll', array( 'type' => 'scroll', 'footer_widgets' => false, 'container' => 'infinite-scroll', 'wrapper' => false, 'footer' => false, 'render' => 'nymj_infinite_scroll', 'posts_per_page' => 3 ) );Initial Archive Loop
<div id="infinite-scroll" class="article-box__body has-custom-scrollbar"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); include( locate_template( 'templates/article-snippet.php' ) ); endwhile; endif; ?> </div>
The topic ‘Infinite scroll repeats initial posts’ is closed to new replies.