• After extensive reading, I think I’ve finally got my head wrapped around Custom Post Types and Custom Taxonomies. I’d just like to clear a things up, and have a small discussion regarding them.

    First and foremost, if I understand correctly, “Categories” are a hierarchical taxonomy that belongs to the “Post” Custom Post Type (technically not custom, but for the sake of clarification I’ll call it that), and tags are a non-hierarchical taxonomy belonging to “Post” as well, correct? This means the name of the custom taxonomy is “Category” or “Categories” (not sure which, I forget), and that the “terms” within that taxonomy are whatever categories you create.

    Given this relationship, if I was to have a website with Lodging as a section (the site covers many other topics), how would I handle the relationship between CPT and taxonomies? I would want a CPT to keep things clean, so I would call that CPT Lodging. I would then want the following taxonomies:

    Lodging
    -Hotels
    -Inns
    -Bed And Breakfasts
    -Resorts

    Would naming the custom taxonomy conflict with the CPT name? If so, what’s a best practice to get around that? In my example, Lodging is like “Categories” is to “Posts”, and the 4 types are the created “Categories”. Given this, how would I retain a url structure like so? site.com/lodging/hotels/hotel-name

    I’ve been trying really hard as of late to wrap my head around all of this (code included), but I have to make sure I get it before I dive in, or I’ll just make a mess. Does it seem like I understand everything correctly, or am I off? Do you have anything else to add that might help me?

Viewing 2 replies - 1 through 2 (of 2 total)
  • For your example, I’d suggest that you stick with the custom post type of ‘Lodging’ and set up a taxonomy of ‘Type’ and have that set up with terms of ‘Hotels’, ‘Inns’, etc.

    But… I don’t think that this will get your URL’s looking like you want. You’d get something like site.com/lodging/hotel-name/ but most likely not with the extra part in there. In reality that shouldn’t be your greatest concern though as the URL structure won’t make that much difference really.

    Thread Starter Gemfruit

    (@gemfruit)

    The url structure is mostly important because of the way I want the breadcrumbs to work. site.com/lodging is the main hub, that’s where you’ll see everything related to lodging, in a very customized, non-directory like page. From there, you can click on any sub-type, and go to a directory style page of all hotels, all inns, etc, so the url structure just seems more logical that way. If a user is looking at hotels, I want it to be easy for them to use the breadcrumbs to go back to the main hub, and switch to inns.

    That being said, your structure for the types sound correct, it’s just the urls I would have to worry about. I believe I should be able to achieve the url I want by writing some custom code with the re-write API, as it’s made for situations just like this. In addition, there’s the with_front property of custom post types and taxonomies, which may give me further ability to get it working, I’m just not sure exactly how.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Types and Taxonomies’ is closed to new replies.