I'm wondering what code I will need in order to add a custom field to a custom post type that will allow me to link it to another custom post type that has already been created.
For example, the site has 'Spaces' and 'Buildings' as two different custom post types. When adding a new 'space' post for lease or sale, I need to link that space to an existing 'building' post. Basically I want the spaces to live within the buildings almost like a parent, but as two separate custom post types.
So, the admin field must create an array of all of the existing 'buildings' custom posts, and then allow the user to choose one to link too. I've been messing around with foreach loops, but can't seem to even generate a list of the buildings. Any help is greatly appreciated!!