Skip Navigation

[Resolved] Help understanding multiple parent-child relations

This thread is resolved. Here is a description of the problem and solution.

Problem: We have already assigned all the contacts (children) to their organisation (parent), but there are a few contacts (children) which need more than one parent.

If we use the many-to-many relationship option, would we still have to go to every single contact and amend - even those which will only remain as before with one single parent organisation?

Solution: Yes, you would likely have to edit every Contact (to remove the current parent Organization association). Then you also have to create all the intermediary posts that link each Contact to each Organization. There are two ways you can do this, either by creating the Intermediary post directly and selecting both parent posts in its Post Relationship editor, or by using the Post Relationship editor in the parent Contact or Organization post's editor screen. So as you can see it's not as simple as just editing the Contact. It may be possible to write a custom SQL script that modifies the database directly, but there is not a good way to migrate existing relationships like this from wp-admin.

0% of people find this useful.

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.58 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 3 voices.

Last updated by Christian Cox 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#611110

I'm working on the domain: hidden link

I have a contacts directive with lists with people related to our project. In this directory, visitors may use filters to find people related to spesific organisations. We also have an organisations directory which display people within their organisation.

The problem is that some of the contacts belong in more than one organisation. I've understood it's not any way of getting more than one parent. Another option would be using a taxonomy, but I would like to avoid this since we have already uploaded hundreds of contacts. Could you explain how I could use a custom post type to do this? Would doing it this way also require changing all the existing contacts?

Kind Regards,

#611145

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Rachel,

Thank you for contacting our support forum.

From what I gather Contacts would be the child post correct? The main issue here is with using a CPT you would still need to go through the process of adding each contact to their parent. This is made even more complex if its a Many to Many relationship.

I would recommend using the taxonomies to proceed with this as its easier to adopt to your existing data structure.

Please let me know if you have any questions on this.

Also you are more than welcomed to take a look at our relationships document
https://toolset.com/documentation/user-guides/creating-post-type-relationships/

Thanks,
Shane

#616035

Hi Shane,

I've had a look, but it would make more sense to our project to use many-to-many relationships.

We have already assigned all the contacts (children) to their organisation (parent), but there are a few contacts (children) which need more than one parent.

If we use the many-to-many relationship option, would we still have to go to every single contact and amend - even those which will only remain as before with one single parent organisation?

Kind Regards,

#616075

Hi Shane is unavailable today so he asked me to look after some of his tickets. I hope that's okay with you.

We have already assigned all the contacts (children) to their organisation (parent), but there are a few contacts (children) which need more than one parent.
As Shane mentioned this would require a many-to-many relationship. This process requires a third, intermediary post type, which is set to be a child of both the Organization and the Contact post.

If we use the many-to-many relationship option, would we still have to go to every single contact and amend - even those which will only remain as before with one single parent organisation?
Yes, you would likely have to edit every Contact (to remove the current parent Organization association). Then you also have to create all the intermediary posts that link each Contact to each Organization. There are two ways you can do this, either by creating the Intermediary post directly and selecting both parent posts in its Post Relationship editor, or by using the Post Relationship editor in the parent Contact or Organization post's editor screen. So as you can see it's not as simple as just editing the Contact. It may be possible to write a custom SQL script that modifies the database directly, but there is not a good way to migrate existing relationships like this from wp-admin.

Let me know if you have additional questions about that.