WordPress tags and categories cannot share slugs

There is a very frustrating bug in WordPress that seems to not allow you to use the same slug for both a Category and a Tag.

http://www.mysite.com/category/computers
http://www.mysite.com/tag/computers

When creating Categories or Tags, WordPress will automatically append a `-2` to any duplicate slug. In other words, if you try to create a Category and a Tag both named “Computers”, WordPress will make sure one of the slugs is spelled `computers-2`. If you then try to edit the slug for the Category or Tag to remove the `-2`, it will not allow it and give you an error.

Since Categories and Tags are two different things, duplication of a slug should not be an issue. If you Google search “wordpress category and tag slug”, you will find a lot of complaining going back a very long time, and a lot of closed support threads at wordpress.org without any official responses.

However, there is a workaround to this issue.

Example:

– desired Category and Tag name: “Computers”
– desired slug: `computers`

1. Make sure no Categories or Tags already exist with a slug spelled `computers`.

2. Create the “Computer” Category first and if you leave the “Slug” field blank, WordPress will automatically create the slug `computers`. You can also type “computers” into the Slug field when creating this Category. The important thing here is to make sure your slug is spelled correctly before moving on.

3. Create the “Computer” Tag. At this step, you must manually create the slug `computers` by typing “computers” into the “Slug” field. Otherwise, if you leave the “Slug” field blank, WordPress will create the slug automatically, it will be spelled `computers-2`, and WordPress will not allow you to remove the `-2` through edits. You would have to delete the Tag entirely and start over.

That’s it. There are other workarounds to this issue which involve creating Tags on the fly when the corresponding Category already exists. However, the steps I’ve outlined above are the simplest. Good luck!

Leave a Reply

Your email address will not be published.

%d bloggers like this: