[wp-hackers] Posts 2 Posts: Pagination for connected posts on single post template

J.D. Grimes jdg at codesymphony.co
Thu Jun 27 13:38:08 UTC 2013


Have you tried get_query_var( 'paged' ) instead?

- J.D. Grimes

On Jun 27, 2013, at 5:07 AM, Md Mahmudur Rahman <iammahmudur at gmail.com> wrote:

> Hello Hackers,
> 
> I'm using Posts 2
> Posts<http://wordpress.org/extend/plugins/posts-to-posts/description/>
> plugin
> to create connection for artists and posts. This way the site can display
> the artist details and connected posts (news/photo galleries/videos) about
> the artist on a single page.
> 
> I modified the single-artist.php to show the artist details (primary loop)
> and connected posts (secondary loop) below it. I can get the connected post
> and paginate them by the following code but the pagination links are not
> working.
> 
> // Find connected posts
> $connected = new WP_Query( array(
>    'connected_type' => 'artists_to_posts',
>    'connected_items' => get_queried_object(),
>    'paged' => (get_query_var('page')) ? get_query_var('page') : 1,
> ) );
> 
> As a result, when I am going to
> http://localhost/artist/artist-name/page/2 redirects
> me back to http://localhost/artist/artist-name/ so I can't go to the
> paginated links and can only see the most recent connected posts.
> 
> Here is:
> 
> *single-artist.php<https://gist.github.com/iammahmudur/19d944872cfac1c285cf>
> *
> 
> I know the single post template is only meant to show the current post, so
> I'm not sure what should I do in this case. Hope someone can give me a
> clue.
> 
> -- 
> *Many thanks*
> *
> *
> *Mahmudur Rahman*
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list