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 badges1 Answer
Reset to default 4There 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
.
本文标签: One to many custom post relationships
版权声明:本文标题:One to many custom post relationships 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741262085a2367813.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论