Integrate nice pagination in wordpress themes

Do you want nice pagination on your wordpress themes?. This is sort tutorial how to get nice pagination using plugin but no ned to activate plugin. So we have to do litle hack the plugin.

Step1. Download WP-PageNaivi plugin.

WP-PageNavi is a WordPress plugin, created by Lester Chan. After you download the plugin, unzip it, copy and paste the folowwing files, to your themes directory.

  • wp-pagenavi.php
  • wp-pagenavi-css.css

Step2. Editing files.

If you already have basic pagination, just found the following code on your page that you want to display (index.php, categories or archive.php). Usualy found after post looping.

<div class="navigation">
<div class="alignleft"><?php next_posts_link('Previous entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next entries') ?></div>
</div>

Replace with code bellow

include('wp-pagenavi.php');
if(function_exists('wp_pagenavi')) { wp_pagenavi(); }

Step3. Do litle hack

Save and refresh your themes page. You will not get nothink. Because this is plugin and you not activated yet. We dont want activate the plugin, so do this litle hack.

open the wp-pagenavi.php file and find the following code (Line 61).

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

Add code bellow to call pagenavi_init.

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

Step4. Adding CSS stuff

Remember to add pagenavi-css.css by adding the folowwing code to your header. Found the folowwing code.

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url');?>" type="text/css" media="screen,projection" />

And add the code bellow.

<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/pagenavi-css.css" type="text/css" media="screen" />.

Refresh your wordpress themes , by now you have to get nice pagination on your wordpress themes. You can also modify the css file for customize the pagination.

Incoming search terms for the article: