• 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

    http://wordpress.org/extend/plugins/posts-to-posts/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author scribu

    (@scribu)

    Have you tried just using the ‘page’ query var instead of ‘paged’, i.e.:

    $guest_interviews = p2p_type( 'guests_to_interview' )->get_connected( $current_id, array( 'paged' => get_query_var( 'page' ) );

    or more readable:

    $guest_interviews = new WP_Query( array(
      'connected_type' => 'guests_to_interview',
      'connected_items' => $current_id,
      'paged' => get_query_var( 'page' )
    ) );
    Thread Starter sqlwiz

    (@sqlwiz)

    That would be much better and simpler, if it worked in this situation.

    I’d have to figure how to stop the url from being rewritten – “/page/2” is being stripped – maybe because is_single() is true?

    Plugin Author scribu

    (@scribu)

    Are you redirected from /slug/page/2/ to /slug/ or what?

    Does it work if you insert a <–nextpage–> into the post content?

    Thread Starter sqlwiz

    (@sqlwiz)

    Yes – /slug/page/2/ becomes /slug/

    No – <!--nextpage--> has the same issue.

    I’d think your suggested approach would work fine with a page, but I need a single-post_type template in this case.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PageNavi integration with Posts 2 Posts’ is closed to new replies.