Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Multiple Custom Post Types

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #207649
    Jtwa11
    Participant

    I’m going to summarize what I’m doing. I may be doing it wrong, so I’m looking for help.

    I’m building a real estate website.
    I have 50 properties, and each property has 10 apartments.So I’ve made 2 custom post types “properties” and “apartments”

    Property 1 has Apt 1, Apt 2, Apt 3…Apt 10
    Property 2 has Apt 1, Apt 2, Apt 3…Apt 10

    I want to assign each apartment to a specific property. I also want access to some of the custom fields from the property when posting an apartment.

    I know there’s a better way, and I should probably be approaching this problem with 50 taxonomies instead of creating a custom post type of properties. I’m here to learn.

    Here’s what I’ve done. I start with apartments and want to get to properties somehow.

    $args = array(
    ‘post_type’ => ‘apartment’
    );
    $query = new WP_Query( $args );
    if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    //For example, I want to access the address of the property.

    #207650
    Senff
    Participant

    I’d say you should start to have one custom post type for “Properties”, and then a taxonomy that determines the type of property, such as “condo”, “apartment”, “business”, “studio”, etc.

    That way, you could sort every property by type; list all properties that are condos, list all properties that are studios, etc.

    Not sure if that’s what you were asking, but from the basic approach, that’s where I would start.

    #207651
    Jtwa11
    Participant

    @Senff So all I need is 1 custom post type?

    However, I’m only dealing with residential units.

    So Building 1 has 10 units (Apt 1 @ $1000/mo. and includes heat and hot water Apt 2 @ $1200/mo but doesn’t include heat and hot water Apt 3 @ $1400/mo includes all utilities etc…)

    All the units in Building 1 will have the same address, same building image and same building description.

    Would you still do it the same way?

    #207693
    Alen
    Participant

    I want to assign each apartment to a specific property

    I would create apartments as custom post type, then create taxonomy properties. Apartments are more unique and might require additional metadata (what’s included, # of bedrooms, etc…), while properties is just group of these apartments…

    So Building 1 has 10 units

    Now you’re changing the terminology. Is it property or building, unit or apartment. Or are there other things we’re not considering. Does property have buildings, etc…?

    I would highly recommend you call things however your client refers to them. If they are familiar with “unit” then use that.

    All the units in Building 1 will have the same address, same building image and same building description.

    You can handle this by creating pages, for example…

    • /buildings/, landing page, lists all buildings
    • /buildings/1-example-building, building 1
    • /buildings/2-example-building, building 2…

    You can then query the database when you’re on this page for example /buildings/1-example-building to pull in all units/apartments that belong to that building.

    same address

    You can use page title.

    same building image

    Feature Image / Thumbnail

    same building description

    WordPress default content editor.

    If you need to attach more metadata see previous link i posted…

    You might need to create some custom logic/templates for each sub-page of buildings so that you can pull in the proper data, appartments that belong to each property/building.

    So the front-end will allow visitors to browse by apartment/unit and by property/building.

    Hope that helps. Alen

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.