WP PageNavi Plugin Adds Pagination In WordPress

47 Flares Twitter 16 Facebook 0 Google+ 3 LinkedIn 1 Pin It Share 0 StumbleUpon 27 Buffer 0 Buffer 47 Flares ×

WP-PageNavi is the most popular page navigation plugin for WordPress having been download more than 2 million times.

If you’re using  a free WordPress theme like the default theme, Twenty Eleven, you may find the site & design options don’t offer pagination so thats where WP PageNavi comes in handy.

The WP PageNavi plugin provides the wp_pagenavi() template tag which generates fancy pagination links.

Simply install and activate the plugin, then go to the settings page to easily configure the plugin. You’ll then need to edit some PHP code.

WP Page Navi Pagination Plugin for WordPress

WP PageNavi Plugin Settings

Here’s a screenshot of the PageNavi Settings

WP Page Navigation Settings

Once you configure and save the settings, you’ll need to find the code in your theme’s files using cPanel or FTP which calls to next_posts_link() and previous_posts_link() and edit this code using a text editor like notepad++

Caution: Always create a backup of your files when editing PHP code.

WP PageNavi in Twenty Ten Theme

In the Twenty Ten Theme for WordPress, the code will look like this:

<div><?php next_posts_link( __( ‘<span>&larr;</span> Older posts’, ‘twentyten’ ) ); </code>
<code>?></div> <div><?php previous_posts_link( __( ‘Newer posts <span>&rarr;</span>’, ‘twentyten’ ) </code>
<code>); ?></div>

Replace the above code with this code:

<?php wp_pagenavi(); ?>

WP PageNavi in Twenty Eleven Theme

If you are using the latest default theme for WordPress, Twenty Eleven, you need to edit your themes functions.php file to use PageNavi.

You’re advised to create a child theme in this case and add the code into your child themes custom functions.php file. This way you won’t lose the changes when you update your theme.

If you don’t want to create a child theme, change the functions between line’s 427 to 436 with this code.

These line numbers maybe a little bit different in your Twenty Eleven theme depending on your existing custom functions.

function twentyeleven_content_nav( $nav_id ) {
global $wp_query;

if ( $wp_query->max_num_pages > 1 ) : ?>

<nav id=”<?php echo $nav_id; ?>”>
<h3><?php _e( ‘Post navigation’, ‘twentyeleven’ ); ?></h3>
<?php wp_pagenavi(); ?>
</nav><!– #nav-above –>
<?php endif;
}

All you need to do is replace this code

<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>

With this code

<?php wp_pagenavi(); ?>

Read more about how to add previous and next post navigation in WordPress using code.

Creating Next & Previous Post Links in Thesis

Check out this article if you want to create post navigation links using the thesis theme for WordPress and want to create posts links.

Adding WP Page Navi in Other Themes

Other WordPress themes may contain lines of PHP code that look something like this:

< ?php next_posts_link('Older Entries') ?>
< ?php previous_posts_link('Newer Entries') ?>

Replace the code with this:

< ?php wp_pagenavi(); ?>

Conclusion

If you are using a free theme which doesn’t offer built in page navigation, you could also install a premium pagination or page navigation plugin so you don’t need to edit any theme files with PHP code.

47 Flares Twitter 16 Facebook 0 Google+ 3 LinkedIn 1 Pin It Share 0 StumbleUpon 27 Buffer 0 Buffer 47 Flares ×
Brad Dalton

Brad Dalton

WordPress Consultant 110+ Hrs/Week, traveler and lover of big surf, making new friends & my family. Read more about Brad Dalton or contact me if you need help with WordPress.
Brad Dalton

@wpsitesdotnet

Howdy! WP Sites creates daily tips & tutorials providing solutions for WordPress users.
Add Social Buttons To Your Nav Menu In Thesis http://t.co/K4IMK0zL0V via @wpsitesdotnet - 10 hours ago
Brad Dalton

Never Miss The Latest Design Tips!

Comments

  1. Jeroen Groenhart says:

    Thanks for sharing this information!

    I am wondering if it is possible to also use WP PageNavi for pagination with pages instead of posts.
    To be specific: Show paginated results of all pages wich are subpages of page “x”. Or perhaps, show all pages with category “x”.

  2. Kim Larsen says:

    I’m working on the newest WP-version, and the RAZOR-theme from Themeforest.

    I have just installed this plugin, and I just can’t figure out how to get it to work.

    As far as I know, the RAZOR-theme doesn’t have any native navigation between posts, so I don’t think there is any code I need to overwrite. So I have just placed the suggested code in the single.php file, and THAT doesn’t work.

    I need the navigation to only navigate in the current posts category. Like if I’m reading a post in “category X”, I can only go back and forth in this category.

    I hope you have the time to help me…

Speak Your Mind

*

Need A Solution for WordPress?

solutions for wordpress
WP Sites offers new posts & 900+ existing tutorials which include:

  1. 1. The basics on using WordPress to build & design a website
  2. 2. Tested PHP & CSS code snippets for easy customization of your theme
  3. 3. Tips, tricks & idea's on how to solve problems with WordPress

 
Enter your email address below & click "Get Updates!"