I have a custom post type to serve as an event calendar and would like to be able to introduce multiple child sessions to each event post with a date and start and finish time accordingly. So let’s say
Event title blah blah
-> Session One Title – 10/05/2018 – 10:00-12:00
-> Session Two Title – 10/05/2018 – 14:00-18:00
I am using the ACF custom fields plugin which actually provides a relationship field type but it does not seem to provide the functionality of being able to add the child type on the parent type edit form but just to select from existing ones.
Any alternatives to that?
thanks a lot!
1 Answer
There many ways to solve this kind or problem, and without more details about what it is you are trying to achieve, it is difficult to give you a precise answer. Keep in mind also that ACF is made to ease the creation and usage of custom posts/fields and not really a tool to build relationships between data constructs. You really ought to code your own data constructs in order to have full control over their relationships.
Here is a general approach that you can use,
- create a custom post type called
calender_event
for example. - create another custom post type called
event_session
. - create a meta-field for the first post type called
calendar_event_sessions
. - Each time you create a a new post
event_session
assign it to an existingcalender_event
and store its post ID as an array into the fieldcalendar_event_sessions
. This also means that when a post is deleted you need to remove it from anycalender_event
.