Search Marketing, WordPress

How To Get Rid of that Pesky -2 Issue with WordPress Slugs

I hope I’m not the only one that this bothers, but I really hate it when I add a category on a WordPress blog and the URL turns into something like /category-2/.

Why Does WordPress Add the -2?

Your tags, categories, pages and posts all have a slug that’s defined in a single table where you can’t have any duplicates between the three areas. What typically happens is that you have a page, post or tag that has the slug so you’re unable to use it as a category slug. Instead of telling you that, WordPress simply numbers the slug with the -2. If you did it again, it would add -3, and so on. Slugs must be unique throughout the entire content management system.

Here’s a screenshot of the issue with one of our clients.

category-slug

How Do I Fix the -2?

First, you’ll need to search pages, posts, and tags for the slug name you want to have. Once you find it, you’ll need to edit that page, post and/or tag to come up with a different slug. More often than not, we see it as a tag and remove the tag from each of the posts. To do this:

  1. Type the slug name that we’re looking for in the search field on the tag page.
  2. A list of posts that the tag was used in is now listed.
  3. The quantity of posts that the tag is used in is indicated to the right of the tag.
  4. Click on that quantity and you’ll get a list of the each of the posts that the tag is used in.
  5. Click Quickedit on each post, remove the tag, and save the post.
  6. Return to the tag page, search for the tag, and you should see that the tag is listed in 0 posts.
  7. If it’s 0, delete the tag.
  8. Now that the tag is deleted, you can update the category slug and remove the -2.

tag-slug

You’re not done yet!

Since your site’s category pages may have been indexed in search results, you’ll want to redirect the old URL with the -2 to the new URL without it.

Leave a Reply