admin管理员组文章数量:1293644
i have two different custom post types - authors and travel reports - i want to link the author to his / hers travel reports. how can i achieve this?
thanks.
wolfram
i have two different custom post types - authors and travel reports - i want to link the author to his / hers travel reports. how can i achieve this?
thanks.
wolfram
Share Improve this question asked Apr 30, 2021 at 6:54 wmarxwmarx 1 5 |1 Answer
Reset to default 1WP_Post
has a property post_parent
by default. Usually this is used for parent-child relationship on hierarchical post types, such as pages, but nothing actually prevents you from linking two different post type posts together with it.
You'll just need a metabox on your travel report CPT, which allows you to select an author CPT post (id) as the parent. This select should have post_parent
as its name so that the value gets saved to the right property.
本文标签: How to create a one to many relationship in two different custom post types
版权声明:本文标题:How to create a one to many relationship in two different custom post types 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741583578a2386713.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp_dropdown_posts
, ACF has similar field type -post object
, where you can select a post type and recieve posts from choosen post type in dropdown view. I guess this field savespost_id
value, so later you a able to show posts by these ids. advancedcustomfields/resources/post-object So, what help do you need here? – anton Commented Apr 30, 2021 at 16:13meta_query
which will be very expensive and does not scale. Taxonomies can group travel reports under a term representing the author, but it isn't necessary to use either meta or terms, Antti's answer references the ideal data storage and best case scenario for performance – Tom J Nowell ♦ Commented Apr 30, 2021 at 18:52