ACF Relationship between 2 CPTs

Greetings and Happy New Year.

I have a Services CPT and a Projects CPT. I also use ACF with a relationship field called project_services on the Projects CPT that lists all the services.

When I create the new Project posts, I see the related services tab and can easily select the appropriate services.

On the single-projects layout I can easily add the list of the selected services with this:
{{dc:acf:post_field field="project_services"}} and setting a headline element with the following {{ post.title }} (I have TWIG enabled.)

I am now trying to create the single-services layout and want to display some related projects. But when I add in the same as above, nothing is output. How are you supposed to add the related projects on services?

Hello @designerken,

Thank you for the inquiry.

Based on the screenshot above, the “project_services” field is only available for the post type “Project”. You may need to edit the Settings > Location Rules and enable the field for the other post type. Let us know if this helps.

Best regards,
Ismael

@Ismael

Actually, I needed to create a related_projects relationship field with ACF. Then set it to bidirectional. Then change project_services to bidirectional as well.

this allows for both CPTs to talk to each other with respect to the services and projects. Then I can adjust the looper for both layouts accordingly.

Doing this sorted my issue.

Hey @designerken,

We’re glad that you’re able to figure it out and thank you for sharing your idea.

Cheers!

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