PageNavi integration with Posts 2 Posts
-
I have the need to get paging working with Post2Post. Our preferred plugin for paging is WP-PageNavi.
We have Shows, Guests and Interviews each as custom post types. A show may have one or more interviews, a Guest may be interviewed on many shows.
On a Guest post (single-guest.php), we want to list the Guest’s Interview posts and be able to page through the list. A typical master/detail display format.
WP-PageNavi will generate the correct page numbers but WordPress will strip the page number from the url and only show page 1 of the results. This is because the PAGED query_var is relative to the guest post type query, not the post2post query.
My solution is to add a query_var (PPAGED), use the wp_pagenavi filter to add the query_var to the generated links and use the p2p_connected_args filter to set paged to the new query_var.
Seems a bit complex, but it works. Suggestions welcome.
Sample code here http://pastebin.com/zpJHk0iz
The topic ‘PageNavi integration with Posts 2 Posts’ is closed to new replies.