SO, I'm having an issue where I need to rewrite a hierarchical custom post type. The custom post type is called "Destinations" and it hold regions, countries, and holidays. There is already content on the site so I can't redo this functionality.

The current structure goes 4 levels deep:

  • /destinations/{region}/{country}/{holiday}/

Each level has it own design type.

What I need is:

  • {region}/
  • {region}/{country}/
  • {country}/{holiday}/

Destinations is completely removed from the URL and the URL level are restricted to 2 levels.

Is there anyway of doing this within WordPress?

  • it's possible, but you'll have to delve into how WordPress resolves requests and do a bit of work yourself to determine what's being requested and set the proper query vars accordingly. you can start by looking at the request and parse_request actions in source and their surrounding code.
    – Milo
    Apr 9, 2015 at 16:27
  • Remoing the post type base is possible, the restriction of the URL level to 2 levels can need some more job and testing. Can you post what you have tried already, working or not, so we can continue the job from that point?
    – cybmeta
    Apr 10, 2015 at 9:11

1 Answer 1


No, this is not possible. Only pages and posts are able to work without a permalink base. When working with custom post types, you always have a permalink base. That's just how WordPress works.

And the third line of your example can't work when country is already a child of region, because the parent-child relation defines the permalink structure.

  • Are you sure it's not possible? How do you suppose WordPress is able to resolve posts and pages with no base? Should it not be possible to do the same thing with custom types using the actions and filters provided in request parsing?
    – Milo
    Apr 9, 2015 at 16:17
  • It's definitely not possible with the standard custom post type API, WordPress works this way to keep the resolve process fast. All categories, tags and posts (and pages) have their own URLs. It registers the bases to know where to look in the database. I haven't looked into your option, but even if that is possible, you would also have to change the way WordPress generates it's permalinks. Otherwise you would have duplicated content (the same content on multiple URLs), which is a bad thing. Apr 9, 2015 at 16:30
  • "with the standard custom post type API" is a huge qualifier to it being not possible. Why do you suppose there are filters and actions to control both request parsing and URL generation?
    – Milo
    Apr 9, 2015 at 16:38
  • You are right, to do what OP wants. But you'll need to be sure what you are doing. Think about the duplicate URL checker for example. Even if you get it all working, there's the speed factor. On every request it would have to go through hundreds, maybe thousands (or on large websites even tens of thousands) of permalinks. It's much faster (for development and for browsing experiences) to stick with WordPress' way. Apr 9, 2015 at 16:52
  • The assertion "Only pages and posts are able to work without a permalink base" is not true. Search this site to find examples of custom post types URLs without the post type base. There are a lot of examples, for example this one. Even if you search the plugin repository of WordPress.org you will find some plugins that do the job. It can be good or bad, but it is possible.
    – cybmeta
    Apr 10, 2015 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.