pagination
Adding Pagination on wordpress is the most popular way to show the post. Instead of showing the default “Next Page” and “Previous Page” links, Pagination allows the visitors to select which page they want to jump to. This is how to build this function into your WordPress theme.

Step 1:

First Download the wordpress pagination Plugin

download the plugin and extract the files.

Step 2:

Find the files called wp-pagenavi.php and wp-pagenavi.css and move them to your theme’s directory.

Step 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(); }
?>

Step 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

Step 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" />
Advertisements