Can't get infinite scroll to work
-
I’ve been struggling to implement infinite scroll for days now, and it’s just not happening for me.
I am using a custom WP_Query as shown here:
<div id="blog-posts"> <?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'post', 'posts_per_page' => 5, 'paged' => $paged ); $post_query = new WP_Query($args); if( $post_query->have_posts() ) : while( $post_query->have_posts() ) : $post_query->the_post(); get_template_part('entry'); endwhile; endif; ?> <?php if( $post_query->max_num_pages > 1 ) { previous_posts_link('« Newer posts'); next_posts_link( 'Older posts »', $post_query->max_num_pages ); } wp_reset_postdata(); ?> </div>
entry.php contains my loop. If required I will post that, but as it’s a little longer and may not be required, I’ve omitted it.
Here is my theme support code from functions.php:
add_theme_support( 'infinite-scroll', array( 'type' => 'scroll', 'footer' => false, 'footer_widgets' => false, 'container' => 'blog-posts', 'wrapper' => true, 'posts_per_page' => false ) );
“To infinity and beyond” is ticked in the reading settings.
Is there something I have missed? I’m really stuck on this one, and I haven’t been able to find a solution online.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Can't get infinite scroll to work’ is closed to new replies.