Posts Tagged ‘wp-pagenavi’

WP-Pagenavi is a great plugin for paginating your WordPress Pages. But there are some cases when it is not working for custom queries like get_posts, query_posts or for WP_Query.

We can do it by using the following method for displaying Wp-pagenavi plugin so that it work fine with the custom queries:

global $paged;
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// default loop here, if applicable, followed by wp_reset_query();

$args = array(
 // other query params here,
 'paged' => $paged

$my_query = new WP_Query( $args );

// custom loop code

wp_pagenavi( array( 'query' => $my_query ) );