What is the best way to correlate one-to-many content-type relationships?

I currently have a custom post type setup for the different buildings that a Real Estate developer owns. Each building can have multiple images, a short description and a few different fields setup in a custom metabox.

I would like to allow my client to add available space listings for each property, and I’m stuck on the best way to integrate listings with the buildings. The available space listing would require a few fields including square footage, price and an image.

Read More

I’ve though about creating a listings taxonomy and even a custom post type for them, but the listings are really a 1-n relationship with the buildings, so neither is an ideal solution.

A custom metabox in the building post type seems like it would work, but it would somehow require a way to create multiple instances of the same metabox.

Does anyone have any ideas or suggestions?

Related posts

Leave a Reply

2 comments

  1. I think perhaps an Available Space Custom Post Type, along with custom post metadata for the Available Space CPT, to correlate each Available Space CPT with its appropriate Building CPT, is the way to go here.

    A one-to-one relationship would lend itself well to custom post metadata in the Building CPT itself, but the one-to-many relationship really implies that you should go the CPT route.

  2. Similar to @Chips suggestion above, I would create a custom post type for “Available Space” with meta boxes for the space listing details.

    However, I would create a custom taxonomy for the various “Building” types. The taxonomy would allow you to easily group or sort the “Available Space” posts by the “Building”.