WordPress Add Pagination

The easiest method I found to add a good pagination:

1. Install WP-PageNavi plugin.
2. In the template file, the loop should be like this:

<?php
// The Query,
$the_query = new WP_Query( 'category_name=blog&amp;paged='.$paged );

// The Loop which loops through all the posts of category
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<?php the_content(); ?>
<?
endwhile;
//call wp-pagenavi plugin
wp_pagenavi( array('query' =>$the_query ));

// Reset Post Data
wp_reset_postdata();
?>

3. Change how many posts do you want to display per page in the admin, Settigs/Reading/Blog pages show at most.

 

That’s it, very easy to implement.

This entry was posted in Wordpress. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted September 27, 2012 at 08:18 | Permalink

    Does Astragalus Root genuinely get the job done for smoking cigarettes cessation?

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>