I have a question. I have a custom post type called Place. I have a situation that there can be place in place. I want to have a custom field parent_place
where I could choose a parent of place.
The Place can have none or one parent.
Is there any posibility to list all posts (type = place
) in custom field and choose one of them? In plugins for custom fields I can choose dropbox, radio, etc, but I have to type values. How can I automatically fill in a list of all posts which type is Place?
It depends on what plugin you are using to generate your custom fields.
For example the Advanced Custom Fields plugin has this option built in – the field type is called “Post Object“.
Documentation:
ACF > Field Types > Post Object
Screenshot:
As Michal Mau points out, ACF is easy and effective to automate this kind of Custom Field/Meta Box management.
The manual mode uses the action hooks
add_meta_box
andsave_post
. In this example, you’d have to adjust the indicated arrays to simplyarray( 'place' )
. Check comments for details: