WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type - Creating Sub Pages (4 posts)

  1. fordp
    Member
    Posted 2 years ago #

    Let's pretend I'm making a custom post type for "Books", and I want tabs for "Author Biography", "Where to buy" and "Reviews".

    What is the best way to create these pages automatically from the posts meta data?

    I want my url structure to be:

    mysite.com/books/to-kill-mockingbird/author/
    mysite.com/books/to-kill-mockingbird/purchase/
    mysite.com/books/to-kill-mockingbird/reviews/

    Reviews will be the default comments. I tried searching and can't figure it out. Essentially, I want to automatically create a comments subpage - but I don't want to use jQuery to switch tabs, I want these to be bonified pages.

    i.e.

    Comments on posts will be split off onto another page, with the structure /post-name/comments

  2. bcworkz
    Member
    Posted 2 years ago #

    You really need to keep everything as a single post/page, using javascript to display the appropriate tabs. If you really need the url structure, use .htaccess to redirect to your actual page with parameters javascript can use to display the correct tab, while passing the virtual mockingbird/author/ etc. path thru unchanged to the client.

    It's not structured as you want, but it looks and functions exactly as you want.

  3. fordp
    Member
    Posted 2 years ago #

    I did this tonight, and right after I finished doing so I reverted all of the changes.

    The problem with using this method is... it sucks in my opinion. You can change the url in the browser with jquery ui using something like
    $('#tabs ul li a').click(function () {location.hash = $(this).attr('href');}

    BUT the issue is, if someone were to search "to kill a mockingbird reviews" and my page were to appear, it would appear like this (using wordpress codex as example): google search screenshot

    This would not be sufficient. I realize that:
    mysite.com/books/to-kill-mockingbird/#reviews
    *could* appear as opposed to
    mysite.com/books/to-kill-mockingbird/
    with the jump to, but I really want real pages:
    mysite.com/books/to-kill-mockingbird/reviews/

    This would be the correct solution from every perspective.

    Virtual Pages
    I did find some information tonight, I'll have to look into it more tomorrow as I'm exhausted from a 12 hour day:
    http://betterwp.net/98-wordpress-create-fake-pages/

    His method looks pretty rough, but it should get me thinking a long the right lines.

  4. fordp
    Member
    Posted 2 years ago #

    Okay so I figured out how to get it to work:
    http://crampedfingers.com/create-post-sub-pages/

    I did it a little different than the previous tutorial. In my case, I needed to use a lot of custom fields :)

Topic Closed

This topic has been closed to new replies.

About this Topic