WP-PageNavi: Version 2.74

Two new improvements come with this version:

Using wp_pagenavi() with custom queries

The old way (which still works):

query_posts( array( 'tag' => 'foo', 'paged' => get_query_var('paged') ) );

while ( have_posts() ) : the_post();
	the_title();
	// more stuff here
endwhile;

wp_pagenavi();

wp_reset_query();	// avoid errors further down the page

The new way (better, because it has less side-effects):

$my_query = new WP_Query( array( 'tag' => 'foo', 'paged' => get_query_var('paged') ) );

while ( $my_query->have_posts() ) : $my_query->the_post();
	the_title();
	// more stuff here
endwhile;

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

wp_reset_postdata();	// avoid errors further down the page

Notice that, in both cases, I included the ‘paged’ parameter. Without it, you would see the same posts on all pages.

‘smaller’ and ‘larger’ classes

Each link has now an additional ‘smaller’ or ‘larger’ class, depending on where it is, in relation to the current page.

For example, if you’re on page 2, the link to page 1 will have the ‘smaller’ class, while links to page 3, 4, 5 etc. will have the ‘larger’ class.

This allows even more customization via CSS.

Enjoy.

comments powered by Disqus