Skip Navigation

[Resolved] Best approach to connect a CPT to an intermediary form between two other CPTs

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

Problem: I have 3 post types, "Provider", "Service", and "Hospital". I would like to be able to link all 3 post types in one relationship, so I can show which Services are provided by each Provider, at each Hospital location. How can I link one intermediary post type to all three post types?

Solution: It's not possible to create a relationship between three post types like this. Instead, the best approach is to use a custom checkboxes group field on the intermediary post type between two of the post types. For example, link Providers and Hospitals in an M2M relationship with an intermediary post type, and add a custom checkboxes group field to the intermediary post. Add one checkbox for each Service post, where the value equals the Service post ID. Then you can assign specific services to each Provider, in each Hospital.

Relevant Documentation:
https://toolset.com/documentation/post-relationships/
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

This support ticket is created 5 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.

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 2 replies, has 2 voices.

Last updated by Ahmed 5 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1194702

I have two CPTs - namely 'services' and 'providers' - in a many to many relationship with an intermediary post. I want to add to this intermediary post a third element which is 'hospitals' where these providers provide their service. My first idea was to add a custom taxonomy 'Hospitals'. But then I discovered that toolset doesn't support taxonomies for the intermediary post type. Should I create a new CPT called 'Hospitals' and add it as a child to the intermediary post ? Is that possible? or is there a better approach in your opinion?

#1195112

Should I create a new CPT called 'Hospitals' and add it as a child to the intermediary post ? Is that possible?
It's actually not possible, because you cannot use an intermediary post type in another post relationship. The system does not allow you to choose those post types in the relationship builder.

or is there a better approach in your opinion?
Since post relationships in Toolset don't allow for 3-way connections, my suggestion is to apply a checkboxes group custom field to the intermediary post type between Providers and Hospitals. The checkboxes group should have an option corresponding to each Service. If you set the contents of each checkbox to be the ID of the corresponding Service post, you will maintain a link between this intermediary post and the corresponding Service. It's less automated than post relationships because you'll be manually managing the checkboxes group options, but it will allow you to link all the post types in a meaningful way.

Let me know if you have questions about that.

#1195333

I will take that approach. Thank you!