Skip Navigation

[Closed] Creating intermediate object for multiple CPT with similar fields

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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

Last updated by Luo Yang 9 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#247586

Hi, I'm developing a site using Types and Views, and have CPTs setup like this:

Parent PT
-- Child PT 1
-- Child PT 2
-- Child PT 3
-- Child PT 4
-- Child PT 5

The child post types are actually very similar (as in, they're all twins, but not identical ones), so I cannot (or should I?) group them into a single post type, and each child post type can have many parent posts, so it's clear that I need an intermediate object.

My first question is, should I use a single intermediate CPT to link parent and child posts together, or would I need a separate CPT for each child?
And secondly, I need a way (from my parent CPT) to list all its children, regardless of child CPT, grouped together. Is there a (sane) way to do that?

Thanks in advance.

#247686

Hi Karim,

Q1) It would be a huge work to "separate CPT for each child", I suggest "use a single intermediate CPT to link parent and child posts together",
Q2) Yes, It is possible within Views, please check the document
Creating and Displaying Many-to-Many Post Relationships
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/
section:
Displaying Many-to-Many Relationships Using Views

#249902

Hi Luoy, thank you for your reply.

For question 1, I've deleted all the separate CPTs and made a single intermediate one as you suggested.

As for question 2, I still have a question on how to do this (actually, a question and an observation):

Q2.1) Suppose I have the following post types:

Software Provider, Company, Team, Program. A Software Provider has many Programs, and a Company has many Teams. So far so good. But, when I view a particular Software Provider, I want to be able to list which Companies use Programs that belong to it. Likewise, if I view a particular Program, I'd like to list the Companies that use it. Does that make sense? What would be the best way to do this?

Observation: I've been following the guide you linked to, but since (I think) the documentation was made for an earlier version of Views, I was confused about how to add the filter, since it mentions parents. The correct filter should be for Child posts, where the option "Post where this View is inserted" is present.

Thanks in advance for your help.

#249956

In your case, I suggest you try create many to many relationship between post type Programs and Company.

1) if I view a particular Program, I'd like to list the Companies that use it
please follow our document to display the Companies list
Displaying Many-to-Many Relationships Using Views

2) when I view a particular Software Provider, I want to be able to list which Companies use Programs that belong to it.
You can create a nested view,
parent view list all Programs belong to current Software Provider
child view list as 1)

3) Observation
Yes, you are right
The correct filter should be for Child posts, where the option "Post where this View is inserted" is present.

The topic ‘[Closed] Creating intermediate object for multiple CPT with similar fields’ is closed to new replies.