I am using custom taxonomies with WordPress 3.0.4
I am wondering if anyone knows how to remove the taxonomy base from the URL?
I have seen plugins that do it for categories and tags, but not for custom taxonomies.
For example, I have a custom taxonomy called ‘cities’. I would like my URL structure to be mydomain.com/newyork instead of mydomain.com/cities/newyork
Is there a function or something I can use?
I think this is possible, but you will need to keep an eye on the order of the rewrite rules. To help you with this I recommend a plugin I wrote to analyze the rewrite rules (soon available in the repository, but you can download a pre-release).
First of all, these rules are quite generic, and should thus come at the end of the rules list. The default action is to put them at the top, so we prevent the default and add them ourselves. We already have the generic page rules at the bottom, so we should make them explicit and move them to the top by enabling verbose page rules. This is not efficient when you have lots of pages, but I don’t think there is another way to do it now.
Rewriting the slug (-> to empty) within the taxonomy registration won’t work so I’m not sure what other options you have within WordPress. You’ll probably need to modify the .htaccess directly to fit your needs.
However, a word of caution to this permalink setup; Otto describes the issue quite well here: http://ottopress.com/2010/category-in-permalinks-considered-harmful/ .
Cheers
Noel
I tried the WP No Taxonomy Base plugin mentioned by the plugins author and it did not work for me. At first I was optimistic it would do the trick, but then I noticed all site permalinks continued to retain the base slug. It was only after navigating to one of the link destinations the base slug was removed, but it remained persistent in all site permalinks, which kind of defeats the purpose.
I have heard some people have had success doing what it sounds like you would like to do using the WP htaccess Control plugin. Its author lists the following features:
I personally experienced problems getting the plugin to save my new settings both times I tried it. It wanted to connect to “https” instead of “http” on save and would throw an error when it could not. However, maybe you will have better luck!