CPT relationship

Hi - I have a site with two CPTs; ‘staff profiles’ and ‘research projects’. I have create an ACF relationship field attached to the staff profile CPT where they can associate themselves with one or more research projects. On the layout page for the research projects, I would like to list only those ‘staff profiles’ connected to that particular research project via the relationship field.

On the Research project layout, I have created a DIV which is both a provider and consumer via the Query Builder and displays all staff profiles. I can further access the relationship field using another DIV within the looper, outputting via dynamic content the value of the relationship field.

However, this full list appears on every ‘Research Network’ layout page, and I can’t work out how to only show those associated with current research network.

Is there a better way of doing this?

update - it looks like I’ve achieved this with a custom shortcode plugin. If there’s a quick solution via Cornerstone and Dynamic Content, I would be very interested to know.

Hey @geoffmartyn,

Thanks for reaching out!

We’re glad that you’re able to figure it out but if you want to use via Cornerstone and Dynamic Content, these threads might help you.

Hope that helps.

Thank you @marc_a - much appreciated. I’ll give those two post a try.

Hey @geoffmartyn,

You’re most welcome!

As you have created a relationship between the two CPTs, you need to loop the ACF Relationship field, not a Query Builder bringing in all the posts. So when you set your provider, choose ‘dynamic content’ instead and use the ACF name eg {{dc:acf:post_field field=“team”}} then that’ll only pull through the ones assigned to that post.

@RubberDuckers,

Thanks for sharing your ideas, we really appreciate your time and effort.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.