WordPress comes with its own default pagination with links that appear at the bottom of the blog index page. These links are however limited to only Previous and Next. While these links do help users in navigating the blog content, they do not prove very helpful especially when a visitor wishes to quickly browse through the blog content that is embedded deeper into the blog pages.

WordPress allows this to be overridden with the help of a plugin or hook. You can instead display page numbers which allow users to quickly navigate to any blog page they wish. If you wish to choose the easier way out, then here’s a very neat plugin called WP-PageNavi. All you have to do is install this plugin and then write a single of code within your blog index page. The code should look something like mentioned below.

If you are using ‘the twentyfourteen’ theme then replace the below line of code and you are done -

<?php twentyfourteen_paging_nav();   ?>

with

<?php wp_pagenavi(); ?>

What if you want to show pagination on a page where you are using custom post type? Then you will need the following piece of code instead.

<?php
$paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1;
$loop = new WP_Query( array( ‘post_type’ => ‘News’, ‘posts_per_page’ => 3, ‘paged’ => $paged ) );

while ( $loop->have_posts() ) : $loop->the_post();

the_post_thumbnail();
the_title();

endwhile;
?>

<?php wp_pagenavi(array( ‘query’ => $loop)); ?>

See how an array needs to be passed to the wp_pagenavi function. This array should contain the query object that is returned by the WP_Query function in WordPress.

Hope this will prove very useful in customizing your default pagination in WordPress pages.