Skip Navigation

[Resolved] Question about post relationships (many-to-many)

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

Problem: I would like to know if it's possible to have indirect relationships between two different post types. For example, there is a M2M between post types A & B, and an M2M between B & C, is there an indirect relationship between A & C?

Solution: There is only an indirect relationship if there is an unbroken chain of hierarchy. You can filter a View by unbroken chained post ancestors.

Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/how-to-filter-posts-by-their-ancestors/

This support ticket is created 5 years, 11 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)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by pedro.S 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1197910
Sem Título.png

Please see the attached image for many-to-many relantionships among several CPT's.

1 - I will be able to associate Brands to Services, Services to products, etc.
So the fact that they are all interlinked, i will be able to create any association among any of them (not necessarily with it's direct relationship).

PROJECT SEARCH PAGE

2 - I will able to filter a project that is associated to a specific Brand (Brand will be a select), even thought there might not be products associated to that project.
3 - I will be able to filter a project by Products used (Products will be a select)

Are these statements true?

thanks

#1198233

So the fact that they are all interlinked, i will be able to create any association among any of them (not necessarily with it's direct relationship).
Not always. It depends on what you mean by association, and how you plan to use that connection. If you simply want to list connected products, then that is usually possible with nested Views:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/
However, there must be a connection between two non-direct ancestors. In other words, there is no connection between a Brand and a Service without a connecting Project and a connecting Product.

If you want to allow your Users to sort and filter by these connections, then you can follow the instructions here to filter by ancestor: https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/how-to-filter-posts-by-their-ancestors/

2 - I will able to filter a project that is associated to a specific Brand (Brand will be a select), even thought there might not be products associated to that project.
Let's assume you use the ancestor filters as described above to filter a View of Projects. You have a Brand filter and a Product filter, set up as ancestors. When the page loads, all the Projects will be displayed because no filters have been applied. The Brand filter will be active, since it is the most distant ancestor. When the User selects some Brand, any Project that is not associated with a Product will be filtered out of the results, because those Projects have no ancestors with direct connections to any Brand.

3 - I will be able to filter a project by Products used (Products will be a select)
Yes, this is true.

#1198277

Thanks for the clear answer Christian!