How to setup permalink structure for categories, sub-categories, custom post types and custom taxonomies?

I’m struggling to figure out how to setup the URL structure on a new WordPress. I’ve tried several combinations of custom (and default) post types, custom (and default) taxonomies, permalink plugins, etc. and keep running into gotchas. Here is what I want…

Standard Pages

Basic pages should be top level. (Obviously)

domain.com/{boilerplate}

Examples:

domain.com/about
domain.com/contact

State Pages

My website will have a URL for each of the 50 united states. Ideally I would like them at the top level too. I would like these to be a custom post type. This is not an archive. Like so…

domain.com/{state}-xzy

Examples:

domain.com/alabama-xzy
domain.com/alaska-xzy
domain.com/arizona-xzy

Gotcha:

I can’t seem to remove the base on a custom post type. For example, if I name this custom post type states WordPress defaults to this URL structure…

domain.com/{custom-post-type}/{state-name}-xyz

domain.com/states/alabama-xyz

I want…

domain.com/alabama-xzy

I tried setting rewrite->slug = ‘/’. It works for this post type and breaks other permalinks.

State Archive

I want this URL to be an archive of things in this taxonomy (default or custom). This will include all companies (see #5 below) in this state regardless of which industry (see #4 below).

domain.com/{state}

Examples:

domain.com/alabama
domain.com/alaska

Gotcha:

I can’t seem to remove the taxonomy base from the URL. By default WP adds category to the URL structure…

domain.com/category/{state}

domain.com/category/alabama

Industry Archive

I want this URL to be an archive of things in this sub-taxonomy (default or custom).

domain.com/{state}/{industry}

Examples:

domain.com/alabama/attorneys
domain.com/alabama/doctors

Company Pages

I want this URL structure for a company page, within an industry, within a state…

domain.com/{state}/{industry}/{company}

Examples:

domain.com/alabama/attorneys/company-A
domain.com/alabama/doctors/company-B

domain.com/alaska/attorneys/company-C
domain.com/alaska/doctors/company-D

Gotcha:

I would really like to avoid duplicating each industry x 50 (number of states in the USA).

Blog Posts

I want to write blog posts that would all fall under the state taxonomy (see #3 above)…

domain.com/{state}/{blog-post}

Examples:

domain.com/alabama/the-title-of-a-blog-post
domain.com/alaska/the-title-of-a-blog-post

Gotcha:

There may or may not be matching blog post titles, but if they are matching they would be under different state taxonomies.

I can’t seem to get this all to line-up. Suggestions?

Read more here:: How to setup permalink structure for categories, sub-categories, custom post types and custom taxonomies?

Leave a Reply

Your email address will not be published. Required fields are marked *