WordPress.org

Ready to get started?Download WordPress

Forums

hierarchical post_types -- can someone explain? (4 posts)

  1. jennylynneh
    Member
    Posted 2 years ago #

    I posted in the How-to & Troubleshooting forum a few days ago and didn't get a response, but I think I have some fairly complex ideas floating around and either I don't know the right verbage to use to ask the right questions or I really don't understand what I want. ;)

    I hope someone can explain hierarchical post_types to me -- how they are connected in the DB, for example -- and how to set them up in the functions.php.

    I mean, the examples of post_types I found in the Codex all set hierarchy to false, and I know there is a built in function to check if a post_type is hierarchical, but I've found nothing to explain what happens when you set one to true and how to create a parent-child relationship between them.

    I'm not certain post_types can work like this, so please correct me if I'm wrong. I would like a parent type and three child types. The parent type is a website bookmark post_type while the other three are really add-ons. The child types would "inherit" the parent type info, meaning that the parent type post is only stored once but any time any of them are queried, the parent + the child queried is returned. That's my logic, anyway. I just don't know how to set it up, if I'm even right.

    bookmark (parent) - title, article author, (custom field), url (custom field), summary (post body), poster (post author), tags

    review - reviewer (post author), review (post body), tags, comments

    favorite - list owner (post author), notes (post body), tags

    to-read - list owner (post author), notes (post body), tags

    I am using the latest versions of WordPress, BuddyPress, Gravity Forms (though I haven't quite figured that out either) and Suffusion as you can see at http://j2-spn.exit-23.net.

    If anyone can explain how to make this work, I would be extremely grateful. Thank you in advance!

    J

  2. wlindley
    Member
    Posted 2 years ago #

    A hierarchical post_type means that the posts of that type each have a hierarchical structure, just like standard pages. It does not permit you to create child-parent relationships between types. Perhaps you want a custom hierarchical taxonomy (having entries review, favorite, to-read) which applies to your bookmark custom post_type. I have done a few sites along those lines; it takes plenty of planning and careful reading of the Codex to get everything working right.

  3. jennylynneh
    Member
    Posted 2 years ago #

    I thought taxonomy is more like a tag or a category, something for organizing, flagging, sorting or grouping. See how confused I am about these structures?

    I've actually been putting more thought to how I think these bookmarks should work -- I'm a programmer, just not familiar with WordPress' terminology, database structure, or even programming standards. (This might be too mainstream for me. :P)

    So, what you're saying is a post is not, in fact, a "record" at all, which is how I think of it.

    I "assumed" a record contained:

    • post id
    • post title
    • post author
    • excerpt
    • content
    • categories
    • tags
    • status
    • post date
    • custom fields
    • etc

    Thus, in my mind, a custom post_type, would be the creation of a variant "record" such as:

    bookmark_link

    • post id
    • post title
    • bookmark url
    • bookmark author
    • post date
    • categories
    • tags
    • status
    • fav_count
    • bookmark_count
    • rec_count
    • to_read_count
    • custom fields
    • etc

    Then have a second post_type perhaps which is
    bookmark

    • post_id
    • parent_post_id
    • post author
    • content (summary)
    • rec/review
    • categories
    • tags
    • status
    • favorite_flag
    • to_read_flag
    • rec_flag_
    • custom fields
    • etc

    or I'm thinking about it all wrong...

    I would love to talk to you about how you've done this and see the sites you've done. I've been working on this for over a month trying to work out how to handle this. (And I'd really rather be writing in my spare time...in fact I'm going to miss my deadline if I keep going this way. :P)

    J

  4. jennylynneh
    Member
    Posted 2 years ago #

    After giving the whole thing more thought -- gotta love the pitch dark commute now that Daylight Savings is over -- I can see the benefits of using separate taxonomies for the Fic Author and the Bookmark URL.

    A Fic Author can be associated with more than one story and, thus, more than one URL. As such, it needs to be a one-to-many functional field. Fic Authors already in the list can be selected or a new one can be added.

    Making a Bookmark URL its own taxonomy allows post authors to each assign his or her own variation of the Title (even though my inner standardization nerd is balking at that) -- making it more meaningful or correct or whatever. It makes the actual bookmark more flexible, more searchable.

    Though I wonder if a function can be written so when a post author uses a bookmarklet on his or her browser on a website, the URL can check the existing posts for a Title and Fic Author and "suggest" one at random or failing to find one, pull in that information the way delicious does?

    J.

Topic Closed

This topic has been closed to new replies.

About this Topic