WordPress.org

Ready to get started?Download WordPress

Forums

Custom post types hierarchy Child a different post type than Parent (5 posts)

  1. jaredvd
    Member
    Posted 2 years ago #

    I'm wondering if it's possible in wordpress to have a child be a different custom post type than a parent.

    For example:

    Parent:Post Type A
    Child:Post Type B
    Child of Child: Post type C
    and so on

    Thanks

  2. jaredvd
    Member
    Posted 2 years ago #

    From some research it looks like this is not possible.

    seems like my options are the following:

    1.Custom table in the database which will add the relationships

    2.Custom post type with all of the info needed. At the top end some fields will be left blank and not displayed.

    If anyone has other ideas, or experience with this, let me know

  3. rickleijtencom
    Member
    Posted 2 years ago #

    Not quiet sure what u want to achieve with it, might tell us that so we can give some hints for your setup?

  4. jaredvd
    Member
    Posted 2 years ago #

    the basic structure of the data i would like to have is
    region -> state -> city -> street -> address (marker)

    The website will be user driven.. Users will be allowed to create cities in states, streets in cities, and markers on streets.

    This way users can go to Region 1 -> State 1 -> Add City

    or Region 1 -> State 3 -> City 5 -> Add Street

    When the user creates a Marker, they will always be coming from a street page, and the marker will always be a child of that street. Street will always be a child of the city, and up the list.

    Hope this is clear enough

  5. jaredvd
    Member
    Posted 2 years ago #

    To explain my thoughts on how to do this I could have custom post types:

    Region, State, City, Street, and Marker and a table in the database:
    ID: Rel_ID
    Parent: Post ID
    Child: Post ID

    When the user creates a Street, it will create a custom post: Street, and add the ID to the Child ID. It will also find the ID of the city they are in, and add that to the parent ID.

    Otherwise I could create one massive Custom Post with the following values:
    Region:
    State:
    City:
    Street:
    Marker:
    whatever other content needed:

    For my regions, I would have to only populate the "Region" field. For States I could populate Region and State... or only have field for the user to enter the state... this is quite obviously not the way to do it... but would be faster to get running

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.