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
WP_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.
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.com/resources/post-object So, what help do you need here?meta_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