I’m creating a simple CMS for real estate.
I have the following Custom Post Types: Renters and Buildings, and need to reference what Building is a Renter renting.
Solved it using a relational field so I can select an existing Building when editing a Renter.
There are commercial Buildings with several Rooms for rent.
For now a Room is a Custom Field (Repeater) and must be directly connected to a Building (CPT).
How can I make both – Buildings and Rooms – appear when editting a Renter?
Thank you in advance!
The relationship field will only be able to save data about a post_id, so unfortunately what you want to do is not possible with this field.
Essentially, what you are describing is a relationship from a render to a building with metadata on the connection. The metadata states the room in the building.
I think a solid solution will be to use the posts 2 posts plugin instead of the relationship field.
It is a very flexible plugin which requires good PHP knowledge, but has good documentation so it’s not too hard to get started with it.
That plugin will allow you to create these connections with the extra ‘meta’ data on each connection.
Hope that helps.
I read a little about Posts 2 Posts but I think there is a problem: I can create a CPT for Rooms and manually attach them to a Building, but the registration would be complex and time consuming (multiple screens, etecetera).
Except there is a way to edit a Custom Post Type inside another CPT. I think the plugin Types do something like this. Type’s custom post types works fine with ACF? They can load my custom fields?
Thanks in advance. ACF is simply the best way for creating consistent CMS in a easy and fast way!
I don’t think you need a post type for rooms.
Just have a post type for buildings and renters. Then connect a renter to a building with a ‘metadata’ of ‘room’ = ‘whatever’.
Because the connection information is setup in your functions.php, you could dynamically create the room choices!
Hope that helps.