Skip Navigation

[Resolved] dynamic post fields or CPT relationship

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

Problem: What is the best way to set up my custom post types?

Solution: Use one-to-many relationships to relate parent / child elements, and many-to-many relationships to relate elements that do not necessarily have a parent / child relationship.

Relevant Documentation: https://toolset.com/documentation/toolset-training-course/part-9-many-to-many-relationships-in-toolset/

This support ticket is created 7 years, 4 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
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 4 replies, has 2 voices.

Last updated by garyF-3 7 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#545694

I am trying to: create relationships and display based on a set of data that is custom for different types of CPT.

The structure so far:

Clients (CPT) is a parent of Events - one client to many events
Talks is a parent of Events - One event has many talks
Tracks is a collection of talks that are determined by each client e.g. client one may have 3 tracks about food, another client might have 5 tracks on coding.
Tracks are therefore developed by each client.
Each Talk therefore is a child of both an Event and a Track.

Is this the best way to manage tracks? Or can tracks be a dynamic set of post fields that are created for each type of client?

I visited this URL:

I expected to see:

Instead, I got:

#545751

Hi, I'll do my best to help you set this up appropriately. Please find my responses below:

Clients (CPT) is a parent of Events - one client to many events
So a Client can go to many Events, but can many Clients go to the same Event? I would assume so. Therefore you don't want to have a one-to-many relationship between Clients and Events. You need a many-to-many relationship, so that Clients can go to many Events, and Events can be attended by many Clients.

Talks is a parent of Events - One event has many talks This seems backwards to me. One Event has many Talks, so an Event should be a parent of a Talk. A one-to-many relationship here sounds appropriate.

Tracks is a collection of Talks that are determined by each Client
Okay so it sounds like Tracks are specific to each Client. The Client can have multiple Tracks. That sounds like a one-to-many relationship, where Client is the parent and Track is the child. Then, Talks are associated with Tracks. This sounds like a many-to-many relationship, since many Talks can be a part of a single Track, and Talks could, in theory, be assigned to multiple Tracks.

Tracks are therefore developed by each client.
Got it, that fits with what we discussed above.

Each Talk therefore is a child of both an Event and a Track.
Not quite, because a Talk can be added to multiple Tracks. Each Talk is a child of a single Event, but Talks have a many-to-many relationship with Tracks.

Or can tracks be a dynamic set of post fields that are created for each type of client?
If a client could only create one Track, this might be an option. But since you need to be able to create multiple Tracks per Client, per Event, you wouldn't be able to pull this off with repeated custom fields. You need a CPT called Tracks which is a child of Client, and has a many-to-many relationship with Talks.

Here's some more information about many-to-many relationships using intermediary post types:
https://toolset.com/documentation/toolset-training-course/part-9-many-to-many-relationships-in-toolset/

Let me know if you have questions about my comments so far.

#545953

Hi Christian, firstly thank you for taking the time to reply.

I will today and over weekend see how I get on with this and whether I can get the results I need. Looking at this then I need to setup a new CPT to connect talks to tracks e.g. 'TrackTalks' and then use this to display the results.

Keep this thread open and I will respond once I have tested this. Thank you very much for your assistance.

#546563

Okay sure, I'll mark this ticket as pending your feedback. Let me know when you're ready to continue.

#547381

OK I have this all working OK. I have another issue now but will raise a separate thread.