Pagination for custom WordPress Posts

This is something that should be really easy, and should be automatic but as I ran into some problems with this I’m posting the way I did it here,

First I got the pagination plugin WP-PageNav and installed it.

Then in my custom post Query added following highlighted part,

$loop = new WP_Query(array(‘category_name’ => ‘news’, ‘posts_per_page’ => 10, ‘paged’ => $paged));

then after the end while of the wp loop I added the following code to add navigation,


if(function_exists(‘wp_pagenavi’)) {
echo   wp_pagenavi( array( ‘query’ =>$loop ));



Hope this helps.


Let me know what you think .. :)

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s