Hello !
I have a website that articulates likes this :
Each custom post type will be linked to each other with one or two relationship field(s) like that :
Here is my question : when, for example, the admin create a “shop” that will be linked to a “product” and save, the linked product has to be also updated so that its relationship field show the newly created shop.
Is there a code example to do something like that ?
Thank you in advance !
Hi @cedric_charles,
Would you like to get this functionality on the backend or the frontend?
Please have a look at this tutorial for the frontend: https://www.advancedcustomfields.com/resources/bidirectional-relationships/
Hi @acf-support !
It’s in the back-end. In the front, I can do the ckecks. But the link you gave me is for the back-end no ?
I’m sorry it was a typo. Yes, the tutorial in that link is used on the backend.
Thanks 🙂
Thank you, I’ve adapted the code for two different relationship fields in two different custom post types and it’s working well, thank 🙂 !
Hi @cedric_charles,
would it be possible for you to share the code for different relationship fields in different custom post types you developed? It’s exactly what I need as I’m trying to set up a database for directors / movies.
Edit: I just found out the code here works just fine for two interrelated custom post types.
The topic ‘Link ACF Relationship fields between Custom Post Type’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.