Skip Navigation

[Resolved] Assigning Child with several parents, & searching for Children via them

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

Problem:
So now I have:
Director CPT as parent of Movie CPT
Cast CPT as parent of Actor CPT and Movie CPT
Production Group as parent of Producer CPT and Movie CPT

Is it possible to search for a Child (Movie) by associated relationships (Actors) of it's parent CPT (Cast)? And if so, how so?

If not, then do you think it's possible to implement some naming methodology for the intermediary CPT that includes the actors that would allow for this?
Solution:
A1) Cast CPT as parent of Actor CPT and Movie CPT
To setup many-to-many relationships between post types "Actor" and "Movie", you will need to setup "Cast" as child post type of "Actor" and "Movie".
See our document:
Creating and Displaying Many-to-Many Post Relationships
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/
Same as above, I suggest you setup Many-to-Many relationships between below post types:
Movies and Directors
Movies and Producers
A2) Is it possible to search for a Child (Movie) by associated relationships (Actors) of it's parent CPT (Cast)? And if so, how so?
Yes, it is possible to search for a Child (Movie) by associated relationships (Actors), see above document:
Displaying Many-to-Many Relationships Using Views
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/#4
Relevant Documentation:

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

Author
Posts
#405298

I need some advice on setting up the relationship structure of some CPT's and then how to parametrically search them.

I have been testing toolset with a basic book archive site, Books CPTs are Children of Publisher and Author CPTs. So Books, Authors and Publishers can each have their own page, with the relevant content from each of their associated projects displayed on each page. This is great.

But what about a more complex archive, let's say a Movie industry archive site.

So now I will similar CPTs, at a minimum I will need Movies, Directors, Producers, Actors, and could include Cinematographers, Music Directors and many more.

Sticking with just the 4 main CPTs for ease, Movies, Directors, Producers, & Actors.

I would set the Movie post types as children of the Directors, Producers and Actors. This is all very much the same as the Book archive. The difference arises in that a Book usually only has one author, but a movie can have several Producers and will have many actors.

I understand that I can create a Many-to-Many relationship between Movie CPTs and these other CPTs through the use of an intermediary CPT.
https://toolset.com/faq/how-do-i-associate-one-child-with-several-parents-of-the-same-type/

So let's say I create 2 other CPTs called Cast and Production Group to act as intermediaries. Because I need these new CPTs to have a relationship with many Actors and Production CPT's, they will need to be the Parent CPTs while Actors and Producers will be the Children CPTs.

So now I have:

Director CPT as parent of Movie CPT
Cast CPT as parent of Actor CPT and Movie CPT
Production Group as parent of Producer CPT and Movie CPT

Then on my Movie posts I can display the director of the movie, the actors via the cast cpt, and the producers via the production group cpt.

However, let's say I am creating a Movie view for archive and I want to be able to search movies via their actors, which would be a common search method. How do i achieve this?

If I search by parent Cast CPT, the title of the CPT would naturally be something like 'Movie-name Cast', and wouldn't include the names of the individual actors in the group, likewise for production group CPTs.

Is it possible to search for a Child (Movie) by associated relationships (Actors) of it's parent CPT (Cast)? And if so, how so?

If not, then do you think it's possible to implement some naming methodology for the intermediary CPT that includes the actors that would allow for this?

I also found this post, where the author was having a similar problem, but the support worker suggested a workaround:
https://toolset.com/forums/topic/assigning-an-item-to-several-parents-of-the-same-type/

Thank you for your advice, and my apologies if I'm missing something easy to make this work.

Best

Jeff

#405342

Dear Jeff,

Q1) Cast CPT as parent of Actor CPT and Movie CPT
To setup many-to-many relationships between post types "Actor" and "Movie", you will need to setup "Cast" as child post type of "Actor" and "Movie".
See our document:
Creating and Displaying Many-to-Many Post Relationships
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/
Same as above, I suggest you setup Many-to-Many relationships between below post types:
Movies and Directors
Movies and Producers

Q2) Is it possible to search for a Child (Movie) by associated relationships (Actors) of it's parent CPT (Cast)? And if so, how so?
Yes, it is possible to search for a Child (Movie) by associated relationships (Actors), see above document:
Displaying Many-to-Many Relationships Using Views
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/#4

#405521

Great, that makes sense.

An Actor can be Cast in many different movies, and movies have a cast of many different actors.

Thanks Luo Yang,

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.