• I have category-exhibitions.php where I am looping the exhibitions category and now I need the pagination part.

    <?php
                $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
                $args = array( 'cat' => 6, 'posts_per_page' => 2, 'paged' => $paged );
                $loop = new WP_Query( $args );
                while ( $loop->have_posts() ) : $loop->the_post();
                ?>
                <div class="news">
                    <div class="small-title"><?php echo get_cat_name(6) ?></div>
                    <div class="main-title"><?php the_title(); ?></div>
                    <div class="details">
                        <p>
                            <?php the_excerpt(); ?>
                        </p>
                    </div>
                    <div class="posted-datetime"><strong>POSTED ON:</strong> <?php the_time( get_option( 'date_format' ) ); ?>  <a href="<?php the_permalink() ?>">READ MORE <i id="arrow" class="fa fa-angle-right"></i></a></div>
                    <div class="red-gray-line" style="width:76%;margin-bottom:5%;">
                        <div class="red-line"></div>
                        <div class="gray-line" style="width:82%;"></div>
                    </div>
                </div>
    
                <?php
    
                endwhile;
    
                ?>
    <?php
                        $big = 999999999; // need an unlikely integer
    
                        echo paginate_links( array(
                            'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
                            'format' => '?paged=%#%',
                            'current' => max( 1, get_query_var('paged') ),
                            'total' => $loop->max_num_pages
                        ) );
                        ?>

    the pagination appears, unfortunately the second page is blank.
    any suggestion or help?

  • The topic ‘Pagination, second page blank?’ is closed to new replies.