I have a situation where i have a lot of tags and i want to add custom taxonomies to sort them. But the thing is when i register new taxonomy i cannot use tag slug.
Example (Tag Taxonomy)
Changed to (Artist Taxonomy)
As you can see, i want to change taxonomy while preserving permalinks. I want to list tags based on couple things. But tags are just tags there is no sorting by type with them. I should have used custom taxonomies from the beginning but its too late now.
If i change tags to new taxonomy it will look like this
And i will have a lot of 404 pages. How do i even redirect 1k pages? Especially since they are just part of the tags. I would really have to add redirects one by one.
You shouldn’t and most likely can’t achieve what you are looking for. The
tag taxonomy term is reserved by WordPress itself, as well as a couple of other terms. Take a look into this page from the codex.
If you use the same slug for different taxonomies, that would defeat the purpose. For example, categories and tags are taxonomies themselves.
Imagine having two categories,
/dog/, both pointing to
/animals/. The WordPress itself won’t allow you to do that, but let’s say you do this by hacking the database. What should be shown when you visit
/animals/ slug? cats or dogs?
The worse scenario is to even mix different taxonomy types. Then the WordPress can’t even decide what template file to use!
Unfortunately WordPress is not optimized to make this happen for you just by writing a simple rule. I myself had to redo a lot of works sometimes, just because i didn’t to it the proper way at the beginning. Your other option would be to write an SQL query or a plugin to alter the data for you and save it in a new format.
Even if you write some rewrite rules to achieve this, you will end up with a messed up website, random 404 pages and incorrect content output.
There are plugins available that will convert taxonomies – search for something like “taxonomy converter” and you will find some.
After you’ve converted them, a simple .htaccess redirect will take care of the URLs:
RewriteEngine On RewriteRule ^tag/(.*)$ http://example.com/artist/$1 [R=301,L]
This will redirect anything under a /tag/ folder, save the subfolder (i.e. artist-name) and redirect it to example.com/artist/artist-name – for all artist-names.
Just change example.com and place these lines above the default WP .htaccess contents.