How to Add Pagination to WordPress Pages and Posts to Help

If you looking for add pagination to WordPress for your pages and posts, then this perfect article for you.

Pagination allows website visitors to go back and forth multiple pages of content, without clicking the repetitive, older posts, and newer posts links.

Pagination is triggered when there are more posts than can fit a page. By default, WordPress displays ten posts on a page. Different themes also have different places where one can set the number of posts that can be shown.

As your website blog grows, obviously, not all your posts can be shown on a single page. WordPress, by default, will display a defined number of posts per page, and every other post is either thrown to the older posts or new posts links.

Pagination is an alternative way of making content accessible with people able to jump to a specific page other than the continual clicking of older posts, to reach the last page.

Step 1. Install WP Pagenavi plugin

Log in to your WordPress website.
On the left menu, go to Plugins and click Add New.
In the search address, type in, wp pagenavi.

Install WP Pagenavi plugin

Step 2. How to use WP-PageNavi plugin to add paginations to your WordPress site

To access a theme or child theme, you will need access to your website files either through File Zila t or through your control panel’s file manager.

In your child theme or theme, you need to find the section in the code that handle paginations and replace them with this code snippet.

<?php $paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array('post_type' => 'our-insights', 'posts_per_page' => 6, 'paged' => $paged);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="col-lg-4">
<div class="box">
<h4><?php the_title(); ?> </h4>
<h6><?php echo get_the_date( 'M'); ?> <?php echo get_the_date( 'd'); ?>, <?php echo get_the_date( 'Y'); ?></h6>
<a href="<?php the_permalink(); ?>" class="btn-readmore">Read More</a>
<?php endwhile;
wp_pagenavi( array( 'query' => $loop ) );
wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

Here post type is “our-insights” and make sure post type slug should be unique and should not be same slug as page or post.

For styling we can add some custom CSS as per our need.