Skip Navigation

[Resolved] Many to many relationship w multiple child records

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

Problem:

Link two posts within a Many-to-many relationship multiple times

Solution:

You can connect the same two posts only once with the same post type relationship.

As a workaround, you can setup two one-to-many relationships to replace the many-to-many, for example:

https://toolset.com/forums/topic/many-to-many-relationship-w-multiple-child-records/#post-2366553

Relevant Documentation:

This support ticket is created 3 years, 8 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by John 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#2366289
2022-05-18_19-21-56.png

Tell us what you are trying to do?
Link two posts within a m2m relationship multiple times

E.g. Location m2m to Event Type

A junction object would be used for the date of the event

E.g. Location A has Event B on dates 1, 2, 3

Is there any documentation that you are following?
see image

Thanks

What is the link to your site?

#2366553

Hello,

It is expected result, you can connect the same two posts only once with the same post type relationship.

As a workaround, you can setup two one-to-many relationships to replace the many-to-many relationship, for example:
1) Setup three post types:
- Location
- Event Type
- Location-Event-Type

2) Two one-to-many relationships:
- Location and Location-Event-Type
- Event Type and Location-Event-Type
So you can add multiple "Location-Event-Type" posts to connect the same "Location" and "Event Type" posts

#2367785

I've never worked in any database that imposes this restriction but thank you for the clarification.