1

If I modify the URL of a post, that URL is still being used by the post. If I try to create a new post and use the hidden URL, I'll get an error.

Is there some way to find all of these hidden, unused URLs and delete them?

2

Whenever you change the slug of a permalink on posts ( and custom post types with post capabilities ), WordPress will save the old slug in the post_meta table with the key _wp_old_slug. On a normal installation the old slug should redirect to the new slug using wp_old_slug_redirect(). There are a couple ways to remove them, the easiest is probably SQL directly:

/**
 * Delete posts old slugs from database in WordPress
 */
function delete_old_slugs() {
    global $wpdb;
    $wpdb->get_results( "DELETE FROM wp_postmeta WHERE meta_key = '_wp_old_slug'" );
}
delete_old_slugs();

You may also be able to find a plugin to do the work for you, the first one that I could find is Remove Old Slugs plugin which will also supply you a list of the old slugs which seems neat.

| improve this answer | |
  • Unfortunately, that plugin doesn't seem to work. I had a page called sample-page. I renamed it to sample-page-2 and updated. The plugin doesn't show the old URL. – 4thSpace Mar 28 '17 at 14:53
  • @4thSpace The slug redirection feature hasn't been implemented for pages, only posts ( or post types with post capabilities ). I've tested the plugin and it works as expected, for posts. – Howdy_McGee Mar 28 '17 at 15:08
  • ah - I see. Thanks. Do you know of anything that works for Pages? – 4thSpace Mar 28 '17 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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