Skip Navigation

[Resolved] Child Type connected to two parents of same type

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

Last updated by Luo Yang 7 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#550415

This is a use case that somehow involves both "multiple parents of same type" and "many-to-many." I have already tried setting up my CPTs using both the album/song and the band/event instructions and while both get part of the way, neither solves the issue fully.

(This is a duplicate of a thread I started in Professional support, I wanted to expose it to the broader community for thoughts)

I am setting up a High School sports enthusiast site. Each school competes in multiple sports. In each sport the school may be a member of a different league and a different state classification (for example 8-man football and 1A Girls Basketball). We're using categories for the classes -- that's consistent with the organization of the regular posts. I'm planning to implement leagues as a tag, at the Sport level of the hierarchy.

Given the schools Sterling, Flagler, Arriba and Arvada, we have the following.

Sterling
Football: 8-man League: Prairie Trails
Volleyball: 1a League: Northeast
Girls Basketball: 1a League: Northeast

Flagler
Football: 8-man League: Pioneer
No volleyball team
Girls Basketball: 2a League: Northeast

Arriba
Football: 8-man
No volleyball or Girls basketball team

Arvada
Football: 8-man League: Metro East
Volleyball; 4a League: Front Range
Girl's Basketball: 4a League: Metro East

For the 2017 Football season:

Week 1 (25 Aug)
Sterling at Flagler
Arvada at Arriba

Week 2 (1 Sep)
Flagler at Arriba
Sterling at Arvada

Week 3 (8 Sep)
Arriba at Sterling
Flagler at Arvada

Arvada's 2017 Football season would be as follows
25 Aug at Arriba
1 Sep vs Sterling
8 Sep vs Flagler

Flagler's 2017 Football season would be as follows:
25 Aug vs Sterling
1 Sep at Arriba
8 Sep at Arvada

For the 2017 Volleyball season
5 Sep Sterling and Arvada participate in a triangular meet with Aurora, at Arvada
12 Sep Sterling at Arvada
19 Sep Sterling and Arvada in triangular meet with Pueblo, at Sterling

Bottom line, a game may have two or more schools (never less than two), and it is an item in each school's season. I need to be able to input the whole season's list of games for one school at one go. (Let's say Flagler's 2017 Football season). When I go to Arriba's 2017 Football season I should already see game against Flagler listed. When I go to Sterling's 2017 Football season I should already have the Flagler and Arriba games in the list.

I'm stuck at the post relationships...how I relate a game to two or more seasons. (Additionally, when I get the pulldowns for the connection to the season, I actually need to show the school name, not the season name, since everybody has a 2017 Football season).

Ideas?

#550619

Dear SRoberts,

For the question: how I relate a game to two or more seasons
How do you setup the "game" and "seasons"?
If they are two different post types, I assume one game can relate to multiple seasons, but one season can relate to only one game.

So I suggest you setup "Game" as the parent post type of "Season"
See our document:
https://toolset.com/documentation/user-guides/creating-post-type-relationships/

#550629

I want to verify we have the same understanding of terms here:

(school) Arvada [10]
(season) 2017 Football [20]
(game) 25-Aug at Arriba [100]

This same game is connected to Arriba in the same fashion:
(school) Arriba [11]
(season) 2017 Football [30]
(game) 25-Aug vs Arvada [100]

Or, we can take the terminology out entirely and use the post numbers (shown above in [ square brackets])

Post [100] is related to posts [20] and [30]. Post [20] is a child of post [10], as post [30] is a child of post [11]

What is the relation of post [100] to posts [20] and [30]? Setting [100] as the parent seems counter-intuitive, but I'll try it.

#550660

I don't think we are having the same understanding of terms, in your case I suggest you try these:
1) Create two custom post types "Season" and "Game",
Setup post type "Season" as parent post type of "Game", add a custom date field ("hold time") to post type "Game"

2) Create a custom hierarchical taxonomy "School", and register it to post type "Game",
https://toolset.com/documentation/user-guides/create-custom-taxonomies/

So when you create a "Game" post, you will be able to setup these:
1) It's parent "Season" post
2) The "hold time" custom date field
3) You can choose two or more "Schools" terms

And you can setup a view to list "Game" posts, order by the "hold time" custom date field, and filter by the taxonomy "Schools".

For your reference.

#551034

Your solution gets part of the way to the result I seek. But I think I've caused confusion by the way I've described things, as well as how I'm breaking out the post types. I'm thinking I've gone too complex. Please be patient while I restart my description from the beginning. I'll use both text data and post numbers in the hopes that one is clear for anyone reading this who might like to chime in.

Sports
Football [10]
Volleyball [20]

School Name, Sports
Arriba [100] (child of) Football, (child of) Volleyball
Sterling [200] (child of) Football, (child of) Volleyball
Limon [300] (child of) Football, (child of) Volleyball
Flagler [400] (child of) Football, (child of) Volleyball

Games
[1001] 25-Aug Arriba [100] at Sterling [200] playing Football [10]
[1002] 25-Aug Limon [300] at Flagler [400] playing Football [10]
[1003] 29-Aug Limon [300] and Sterling [200] at Flagler [400] playing Volleyball [20]
[1004] 1-Sep Sterling [200] at Limon [300] playing Football [10]
[1005] 1-Sep Flagler [400] at Arriba [100] playing Football [10]

On data input I want to be working with Arriba Football (school 100, child of sport 10) and input games 1001 and 1005. Then I want to shift to Arriba Voleyball (school 100, child of sport 20) and input game 1003.

When I shift to Sterling Football (school 200, child of sport 10), game 1001 should already be showing up in their list. I should only need to enter game 1004. If I shift to Flagler Volleyball (school 400, child of sport 20), I should not have any data entry to do because game 1003 is already listed.

On the front end, when I select 25-August, I should be shown games 1001 and 1002. When I select Arriba I should see a table for Football, showing games 1001 and 1005, and a table for Volleyball with only game 1003. When I select Football I should see games 1001, 1002, 1004 and 1005, sorted by date.

Does this help clarify? I rethought the data paradigm a little, hoping that would make it more straightforward.

#551167

I assume you are going to wait for the suggestion (chime in) from other users.

OK, please leave this thread in status "Waiting for user feedback", there might be some better solution/workaround for your case.

#551497

Returning to your reply #550660:

How could I use a Schools CPT to populate the term pulldown? It appears ACF can do this, but can Types?

#551892

You can register the taxonomy "School" to both custom post types: "School" and "Game",
when you edit a "School" post, you will be able to assign it with one "School" term.
when you edit a "Game" post, you will be able to assign it with two or more "School" terms.

This is another kind of many-to-many relationships within Types plugin, the Intermediary Object is a custom taxonomy, so you will be able to setup many-to-many relationships between post types "School" and "Game".

The forum ‘Types Community Support’ is closed to new topics and replies.