WP-PageNavi is one of the most popular WordPress plugins. Instead of showing the default “Next Page” and “Previous Page” links, Pagenavi allows the visitors to select which page they want to jump to. This is how to build this function into your WordPress theme.
1. The first thing you must do is download the plugin and extract the files.
2. Find the files called wp-pagenavi.php and wp-pagenavi.css and move them to your theme’s directory.
3. Now you’ll need to replace the old code that calls the default “Next” and “Previous” links with the new code that calls for Pagination. To do this, go to your theme files and replace this:
<?php next_posts_link('Previous entries') ?> <?php previous_posts_link('Next entries') ?>
With this:
<?php include('wp-pagenavi.php'); if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
4. Now we have to do a tiny bit of editing in the wp-pagenavi.php file. So open it up and go to line 61 to find this:
function wp_pagenavi($before = '', $after = '') { global $wpdb, $wp_query;
One you found it, replace it with this:
function wp_pagenavi($before = '', $after = '') { global $wpdb, $wp_query; pagenavi_init(); //Calling the pagenavi_init() function
5. One last step. Make sure your blog can locate the pagenavi stylesheet by going into your header.php and pasting this between the head tags.
<link rel="stylesheet" href="<?php bloginfo('template_url');?>/pagenavi.css>" type="text/css" media="screen" />


[...] Instead of using the WordPress default previous and next links, this plugin adds a more advanced navigation. You can also completely customize the display of the pagination. We have a detailed How to Make WordPress Use Pagination article. [...]