How To Integrate Pagination In WordPress?

Posted by


In order to integrate your wordpress theme with pagination you need to perform these steps:

1) Download this plugin and install it:

2) Open your theme file where you want the pagination [index.php, search.php or categories.php].

3) Find this code:

<div><?php next_posts_link(‘Previous entries’) ?></div>
<div><?php previous_posts_link(‘Next entries’) ?></div>

Replace with:
if(function_exists(‘wp_pagenavi’)) { wp_pagenavi(); }

4) Now, open wp-pagenavi.php file from the plugin directory and find this code:

function wp_pagenavi($before = ”, $after = ”) {
global $wpdb, $wp_query;

This code should be on the line: 61. Now, we will have to call this function in any of the file where we need to do pagination.

5) Add this code in the file to call the pagination function:

function wp_pagenavi($before = ”, $after = ”) {
global $wpdb, $wp_query;
pagenavi_init(); //Calling the pagenavi_init() function

6) Now, open header.php file from your theme and find this code:

<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />

Now, below this code add this code:

<link rel=”stylesheet” href=”<?php echo TEMPLATEPATH.’/pagenavi.css’;?>” type=”text/css” media=”screen” />

Now, pagination work with your theme.


Shane G.

One comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.