admin管理员组

文章数量:1287541

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!

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!

Share Improve this question asked Apr 17, 2018 at 13:12 KostasKostas 355 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 4

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,

  1. create a custom post type called calender_event for example.
  2. create another custom post type called event_session.
  3. create a meta-field for the first post type called calendar_event_sessions.
  4. Each time you create a a new post event_session assign it to an existing calender_event and store its post ID as an array into the field calendar_event_sessions. This also means that when a post is deleted you need to remove it from any calender_event.

本文标签: One to many custom post relationships