WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Permalinks Should Be More Flexible (8 posts)

  1. TexInWien
    Member
    Posted 3 years ago #

    The fact that Custom Post Types can't be mixed in with Pages in a site's structure is a real problem for some use cases. I've searched and experimented, but haven't found a solution - including looking at using Custom Taxonomies in conjunction with Custom Post Types. If someone's got a suggestion, or I've just overlooked an obvious solution, I'm all ears.

    Problem #1: Posts of a specific Custom Post Type must be arranged under that Post Type's slug
    Problem #2: Pages can't be nested under a Custom Post
    Problem #3: Custom Posts can't be nested hierarchically

    Custom Post Types have been touted as the feature that turns WordPress into a "real" CMS, so I'm going to provide a real-life business scenario here that shows the limitations of the current Custom Post Types restrictions.

    Scenario

    1. EXAMPLE Travel offers travel packages for multiple resorts in each of multiple destinations (e.g. Bahamas, Bermuda).
    2. EXAMPLE needs to record and display structured information about each resort and each destination - so they've decided to create two Custom Post Types - "Resort" & "Destination" to handle this.
    3. EXAMPLE wants to organize its Resorts by Destination, both in menus and in the permalink structure e.g. example.com/bahamas/royal-palm-resort/, example.com/bermuda/elbow-beach-resort/.
    4. EXAMPLE would like to show a list of Resort "teasers" on each Destination page (so, example.com/bahamas/ would automatically show a list of teasers, one for each Bahamas Resort, based on information in each Resort's Custom Post)
    5. EXAMPLE would like to have Destination subpages (standard Pages) that contain details like safety considerations, customs information (e.g. example.com/bahamas/safety/ & example.com/bahamas/customs/).
    6. Similarly, EXAMPLE would like to have Resort subpages (standard Pages) showing details about each resort (e.g. example.com/bahamas/royal-palm-resort/golf-course/ & example.com/bermuda/elbow-beach-resort/scuba-diving/)
    7. EXAMPLE wants to have a standard blog at example.com/blog/ and standard nested pages (e.g. example.com/about/ & example.com/awards/2010-excellence-in-travel/) in addition to the hierarchically-organized Destinations and Resorts.

    Correct me if I'm wrong, but this doesn't seem to be possible (or at least it's not obvious how to set this up) in WP 3.04, at least without jumping through some major hoops.

    I was excited about Custom Post Types as a way to save more structured, searchable information than normal Posts and Pages allow you to easily do, but most of the examples I've seen online are very shallow - a flat collection of books or a catalog of movies. If you want to do anything more complex, it seems you're still out of luck.

  2. Hierarchical Custom Post Type URLs can be done.

    http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress has a pretty good explanation.

    They work 'better' in 3.1 in my experience.

  3. TexInWien
    Member
    Posted 3 years ago #

    My understanding is that that 'heirarchical' setting applies only to a single Custom Post Type.

    That is, in my examples above, it would not be possible to hierarchically nest Resort posts underneath Destination posts.

  4. I'm not sure what you mean here...

    You make Destination as a CPT and make it hierarchical.

    You make Resorts, Flights, Mambo-No-5, etc as CPTs with Destination as their parents.

    Is that not what you want? You can totally have multiple CPTs as children under a parent, but you cannot (to the best of my knowledge) have the same children under multiple parents. That would defeat the purpose of CPTs, really.

  5. TexInWien
    Member
    Posted 3 years ago #

    Has something changed since this thread?

    I played around with this a few weeks ago and wasn't able to get it to work, but I may have missed something. It's also possible that something's changed since then.

    From the linked thread:

    dashaluna: When 1 or more posts of custom post type exist then any of them can be a parent of another post of the same (!) custom post type.

    Ipstenu: Ah, that makes sense, actually, since CPTs are posts/pages and not categories

    I don't want to bug too much, but I also don't want to waste time re-coding my CPT experiment if it's not going to work.

  6. As I mentioned, they work better in 3.1 :) Try 3.1 RC4 (it's stable enough for daily use) and see if that helps?

  7. jszkut
    Member
    Posted 3 years ago #

    I'm curious about case #2/3 also. I checked out the blog post linked, as well as the other thread, and the question isn't exactly answered.

    I have two custom post types, Chapter and Part, both defined as hierarchical. I would like to be able to assign 'Chapter' posts a parent post of type 'Part'. It doesn't appear that this is possible at the current time, though. Only posts of type 'Chapter' are available when choosing a parent for a Chapter, and only posts of type 'Part' are available when choosing a parent of a Part.

    I am on 3.1, by the way. Am I missing something?

  8. jszkut
    Member
    Posted 3 years ago #

    If anyone's curious, I've solved this. See the code snippet at http://janina.tumblr.com/post/3588081423/post-parent-different-type.

Topic Closed

This topic has been closed to new replies.

About this Topic