For a client project, I needed to display recent blog posts on a custom page. I used the standard WP_Query method of pulling a custom page loop (this post does a nice job of breaking down all the possible WordPress loops), but I had a problem. I wanted to use the WP-PageNavi plugin, but I couldn’t get it to work. I would click on the next page, and instead of loading page 2 of posts, it would show page one…even thought the URI clearly indicated page 2.
I found some advice that suggested resetting my permalinks, but that didn’t help. I also found a few blog posts that claimed to solve the problem, but none of them worked either. Fortunately, the trusty old WordPress CODEX had enough documentation of the WP_Query function that I was able to figure it out.
After hours of testing and searching, I arrived at the following solution:
1, 'paged' => $paged ); $loop = new WP_Query($args); while ($loop->have_posts()) : $loop->the_post(); ?> **DO LOOP STUFF**$loop )); } ?>
The key is that the syntax for the get_query_var function changed as of WP 3.02 – the proper way to grab the page ID changed from
get_query_var( 'paged' ) to
get_query_var( 'page' ) – that’s paged to page.
Deleting the ‘d’ made it work.