• Hello,

    I am about to implement custom post types for my website (with large
    amounts of pages) and I have 2 questions:

    1. I have found that you can’t nest custom post types, and I am (was?)
      planning on having subdirectories. Is there a solution to this?
    2. This may be off topic, but what if I didn’t have multiple subdirectories
      (I would just have one)? Does that affect SEO negatively?

    Any input is appreciated. ?? Ken

    • This topic was modified 1 year, 3 months ago by racerman28.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Correct on not being able to have post types be easily related to other post types.

    You could have one post type that’s set to hierarchical and make use of parent/child relationships between the posts in the one post type.

    For example if you had a post type of “movies” as for this example you’re wanting to do some things with franchises. Won’t be an exact match to what you’re going for, but hopefully it’ll work for an illustration.

    You could create a parent post of “Lord of the Rings” and then child posts for “Fellowship of the Ring”, “The Two Towers”, and “Return of the King”. You would get permalinks like:

    https://mysite.com/movies/lord-of-the-rings/fellowship-of-the-ring
    https://mysite.com/movies/lord-of-the-rings/the-two-towers
    https://mysite.com/movies/lord-of-the-rings/return-of-the-king

    Giving an example of a structured hierarchy, all while still being in one post type.

    I’m no SEO expert, so I can’t say for certain whether you’d be hurt or not, but I can’t imagine why you would be either.

    Thread Starter racerman28

    (@racerman28)

    Hi Michael,

    Hey…thank you for getting back to me on this! This makes sense. I’m going to create some examples in my dev site. I think I will have one follow-up…I’ll know once I get something up.

    Thanks!

    Ken

    Thread Starter racerman28

    (@racerman28)

    Hi Michael,

    As per your example above, I made a custom type:

    https://mysite.com/biplanes

    Then a custom taxonomy assigned to it (‘Texas’):

    https://mysite.com/biplanes/texas

    So can ‘biplanes’ be the ‘index’ page for this setup where I can have content residing there? I created a page ‘biplanes’ in the Biplanes CPT so I have ‘biplanes/biplanes’

    That make sense?

    Ken

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    assuming you have the post type set to have an archive, that would be viewed at mysite.com/biplanes/. This could list all the posts however which way you end up wanting with the archive-biplanes.php template file.

    Then a top-most post in that post type, based on your biplanes post, would end up being mysite.com/biplanes/biplanes/

    I’m assuming “Texas” and probably the other states would all be biplanes in this case, and potentially those states would be better treated as the parent posts, though you can definitely keep them as taxonomy terms as well. Treating each state as 50 top level posts, would get you mysite.com/biplanes/texas/ URLs and parent posts. Not sure what the plans are for child posts etc beyond that and what you want those permalinks to appear as.

    When it comes to mixing taxonomies/terms into the permalink mix, we definitely recommend checking out https://www.ads-software.com/plugins/permalink-manager/ as a solution, as we don’t have anything for extensive custom rewriting in CPTUI, and it’s a bit of a complex topic.

    Thread Starter racerman28

    (@racerman28)

    Yes, so once I created a page named ‘biplanes’ it is now mysite.com/biplanes/biplanes/ (don’t want that).

    So are you saying I would use Permalink Manager to rewrite this? (I have Permalink Manager Pro installed already actually :))

    How do I switch Texas to a ‘Parent Post’ so they’re top level? (apologize, I get tripped up with all the terms….so I appreciate your help!)

    Ken

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    The way I’m thinking of things, is bypass .com/biplanes/ as a traditional archive url where it’s just post after post newest to oldest, and get a bit custom with it, where you perhaps just display a grid or whathaveyou of your biplanes with links them. If you want a UI spot to add some content, perhaps a separate post in the post type that you could fetch/output with the archive-biplane.php template file, for quick content UI.

    In regards to the states being parents. Just make those top level posts in the post type. They don’t get their own parent, but they will get child posts soon. Then when it comes time to assigning child posts, those would be new posts in the post type, and you choose Texas, South Dakota, Florida, etc as the parent for that post. It takes out the need to use the taxonomy/terms as part of the permalink, and you can still use the taxonomy terms elsewhere for your needs and their own term archives.

    Thread Starter racerman28

    (@racerman28)

    Let me use actual examples (‘biplane’ was an example and I think it made it more confusing :)):

    https://mysite.com/airports/
    https://mysite.com/airports/united-states/
    https://mysite.com/airports/texas/
    —- https://mysite.com/airports/texas/flights-to-dallas-fort-worth-international-airport-dfw

    ‘Airports’ would be the custom post type, and set to ‘archive’. The URL is https://mysite.com/airports/airports

    I would create a page named ‘airports’, (where I list airports by state).

    Then in Permalink Manager Pro I would set the Permalink to https://mysite.com/airports/ which should show
    the page ‘airports’ I created?

    This is what Maciej said:

    ‘By default, if you define the ‘biplanes’ custom post type, the https://mysite.com/biplanes will display the post type archive (that lists all that CPT single items just like “Blog” page with posts does).

    You can use Permalink Manager Pro to mix-up/remap the predefined permalink structures and overwrite this archive with regular page by simply changing its custom permalink to “biplanes”. Then, Permalink Manager will force that new page instead of the archive.’

    And in your idea, ‘United States’ airports would be ‘parent posts, which I still do not understand (maybe because I’m thinking of this like pages).

    Ken

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Used terms are absolutely important, because “page” is a post type, and when people say “page”, technically they’re saying “a post from the ‘page’ post type”. So when you’re saying “page” in these contexts, my head is going “you’re creating something in a completely different post type, trying to use it with this post type. Why not stay within the one post type completely?”

    Have https://mysite.com/airports/ be the archive url. If you’re going with my idea of a separate post that handles some editor screen content, then perhaps make https://mysite.com/airports/landing-page but don’t have it technically public. This could be a matching example of the /airports/airports/. My example just used a more generic name.

    In your archive url above, fetch the content from /landing-page via something like get_post() and display at the top of the archive template file. Then with the rest of the archive template file, start displaying the rest of the posts. This would be where you list airports by state, by them being posts in this post type.

    For your actual example urls, /united-states/ and /texas/ would all be examples of top level posts, and then /flights-to-dallas-fort-worth-international-airport-dfw would be a child post of /texas/. In this example texas isn’t the taxonomy term, it’s still a post.

    If you’re going to be doing other countries as well, then perhaps you could consider a permalink of /united-states/texas/flights-to-dallas-fort-worth-international-airport-dfw

    To try and help simplify how to think about the hierarchy…

    Post type permalink basis: https://mysite.com/airports/

    Everything after /airports/ in the URL is a post. if you do just /texas/ that’s a post, once you create a child post, that gets appended: /texas/flights-to-dallas-fort-worth-international-airport-dfw.

    You could go even deeper and have /texas/flights-to-dallas-fort-worth-international-airport-dfw/gates/ and so on, but then it’s starting to get a little unwieldy. The point is that each / ends up denoting the next child in the hierarchy until there’s no more, and each child could technically get removed, one by one, and see a different post.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Nested Posts Alternatives?’ is closed to new replies.