1

I am using the amazing P2P plugin (many thanks Scribu!) and I am having an issue that is probably right in front of my face but I just can't see.

I have a 'People' as CPT and I have connected that to 'Users' with a 'Person_to_User' connection I created.

On single posts I want to get the connected 'person' in my 'People' CPT from that post author.

It seems like that should be fairly simple to do but my brain is hurting from trying to get this and I can't spend much more time on this.

1 Answer 1

0

On single post, try something like this:

$author_id = get_the_author_meta('ID');

$people = get_posts( array(
  'connected_type' => 'people_to_user', // replace with whatever
  'connected_items' => $author_id,
  'suppress_filters' => false,
  'nopaging' => true
) );

Now $people[0] references the first (and only) author related to the post you're on. So $people[0]->ID can be used to get the various bits of content, thumbnail, custom meta, etc.

1
  • Yes! Thank you so much GhostToast! I would buy you a beer sir if I could. Best.
    – WP Loopy
    Commented Jul 1, 2013 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.