Home WordPress Pagination | How to paginate in WordPress
Post
Cancel

WordPress Pagination | How to paginate in WordPress

This article is the basic introduction to how to paginate in WordPress. It will show you how to do WordPress pagination.

WordPress basic pagination

In your theme, find your index.php file (/wp-content/themes/YOURTHEME/index.php). Add in the following code wherever your want your pagination outside the loop.

1
2
3
4
<pre lang="php" toggle="no"><?php if (  $wp_query->max_num_pages > 1 ) : ?>
<?php next_posts_link( __( '&larr; Older posts', 'twentyten' ) ); ?>
<?php previous_posts_link( __( 'Newer posts &rarr;', 'twentyten' ) ); ?>
<?php endif; ?>

This will give you the good old:

<– Older posts
Newer post –>

navigation.

I personally dont like this and use instead:

WordPress WP-PageNavi

The final result is a navigation like this one:

Follow two simple steps to get this beautiful WordPress pagination:

Step 1

Iinstall plugin WP-PageNavi.

Step 2

Replace code above with:

1
2
3
<pre lang="php" toggle="no"><?php if (  $wp_query->max_num_pages > 1 ) : ?>
<?php wp_pagenavi(); ?>
<?php endif; ?>

This is it. Enjoy your beautiful pagination!

This post is licensed under CC BY 4.0 by the author.
Trending Tags