Support » Fixing WordPress » Pagination stops at page 2

  • Jase

    (@jasewarner)


    Hi,

    I’m experiencing a rather annoying issue and could do with some help.

    I’ve got a static homepage that displays my latest custom post types (two in total).
    The problem is that pagination seems to stop dead at page 2, even though there should be 4 pages in total.

    Here’s the code from my homepage template:

    <?php get_header(); ?>
    
        <div id="masonry" class="row">
    
            <?php if ( get_query_var('paged') ) {
                $paged = get_query_var('paged');
            } elseif ( get_query_var('page') ) {
                $paged = get_query_var('page');
            } else {
                $paged = 1;
            }?>
    
            <?php $post_args = array( 'post_type' => array( 'sound', 'web' ), 'posts_per_page' => 9, 'paged' => ( get_query_var('page') ? get_query_var('page') : 1 ) ); ?>
            <?php $loop = new WP_Query( $post_args ); while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
                <div class="col-xs-12 col-sm-4 item">
                    <div class="inner">
                        <a href="<?php the_permalink(); ?>"><img src="<?php the_field('work_thumb'); ?>" alt="Jase Warner – <?php the_title(); ?>" /></a>
                        <a href="<?php the_permalink(); ?>" class="overlay"><span class="title"><span class="wrap"><?php the_title(); ?></span></span><span class="tagline"><?php the_field('work_tagline'); ?></span></a>
                    </div>
                    <div class="hidden-md hidden-lg">
                        <a href="<?php the_permalink(); ?>" class="sm-title"><?php the_title(); ?></a>
                        <p class="sm-tagline"><?php the_field('work_tagline'); ?></p>
                    </div>
                </div>
    
            <?php endwhile; wp_reset_query(); ?>
    
        </div>
    
        <div id="load-more">
            <?php next_posts_link( 'Load More', $loop->max_num_pages > 1 ); ?>
        </div>
    
    <?php get_footer(); ?>

    I should mention that I’m using infinitescroll.js with this, though I don’t think that’s to blame for the issue.

    Here’s a link to the page where the problem exists: http://217.199.187.196/jw-staging.com/

    Any help would be greatly appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Jase

    (@jasewarner)

    So after some poking around it seems that the problem may actually be infinitescroll.js – when removing the infinite scrolling the pagination works fine.

    Has anybody come across this problem with infinitescroll.js before?

    vtxyzzy

    (@vtxyzzy)

    There can be pagination problems when you try to display CPTs with fewer posts per page than the value in Settings.

    If the value you are using in your template is less than the default, try switching to the default to see if this is the problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pagination stops at page 2’ is closed to new replies.