11

I published an article with permalink slug:

http://domain.com/writing

Then after publishing, I changed the permalink slug to writing-lorem. Now, whenever I visit /writing, it redirects to /writing-lorem.

I want to use the writing slug for a new category but can't, it changes to writing-2.

To attempt to remove all records of the writing slug, I looked in the DB for the post_name column under that post, but the value was the new slug writing-lorem.

Then I search for other posts with the writing value, none found.

Where exactly is that slug stored and how can I remove it so that I can use it for the category?

2 Answers 2

9

It's in the table postmeta with the meta_key of _wp_old_slug

If you wanted to clear all of the old slugs you could use this:

DELETE FROM wp_postmeta WHERE meta_key = '_wp_old_slug';

5
  • 1
    I searched through that meta_key, did not find the relevant slug. Very strange. Is it possible it can be anywhere else?
    – Christine Cooper
    Sep 3, 2014 at 17:32
  • I've been looking through the DB and have only found old slug information in the postmeta table. Are you 100% sure you changed the old slug? I would navigate to the page/post in the admin section and add the "Slug" area from screen-options to ensure it's actually changed. That's the only other thing I can think of. Sep 3, 2014 at 17:49
  • 1
    It is definitely changed, I double checked. It really baffles me, where else could it possibly be.
    – Christine Cooper
    Sep 3, 2014 at 18:14
  • Sorry I couldn't be of any more help. I have no idea where else to look. Maybe this would help. Core Issue 12473 It's only but might be able to shed some light. Sep 3, 2014 at 20:06
  • 1
    Thank you very much for your assistance. I found where the slug was stored, see my answer.
    – Christine Cooper
    Sep 4, 2014 at 13:13
4

We determined that the slug was not stored in postmeta meta_key _wp_old_slug.

In a final attempt to find where this slug is stored. I performed a search for the exact phrase of writing and found a few results. The one of interest was in wp_terms.

I deleted that entry and then changed the slug of the category to /writing and it is working. The strange part was that there were no records within wp_terms that connected the post to the slug.

Maybe someone is knowledgeable about this table...

1
  • 1
    The wp_terms table holds "The categories for both posts and links and the tags for posts". So you must have had a category or tag already using the writing slug. Since slugs must be unique across posts/pages/categories/tags Wordpress appends a number to any duplicate, as you found when you changed the slug of your post.
    – Tony
    Apr 13, 2015 at 13:30

Your Answer

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

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