An Awesome Hidden Feature In WordPress You May Not Know About

An Awesome Hidden Feature In WordPress You May Not Know AboutNow if this feature is common knowledge then feel free to call me out, but I have been a WordPress user for some time and had no idea that it existed. Not only that, I could have saved myself a fair bit of time on occasion if I had known about it.

How often do you get the temptation to change the permalink of a post after you have published it? There are a few different reasons why you might – here are some of mine:

  • WordPress’ interpretation of the post title resulted in a mangled permalink (no one likes “%20″s and “—”s in their permalinks, right?).
  • You started with one title, then edited it before you hit Publish. The permalink is still based upon the original title.
  • You’re going back through some old posts and re-editing titles and permalinks to make them more search engine friendly.
  • You just plain don’t like the permalink that WordPress created (perhaps it is far too long), but didn’t notice before you hit Publish.

So, changing permalinks is often a necessary evil. Before I knew of WordPress’ hidden capability, effecting the transition was a real pain. I would use the Quick Redirect Plugin to prime the redirect from the old URL to the new URL, change the permalink in the post screen, then hit Update on both pages as quickly as possible. Bit of a pain – and easy to get wrong.

Redirects
Redirects - complicated.

It turns out that a much better alternative exists, which is to simply do nothing. That’s right folks – if you change a post’s permalink, WordPress will take note and create a redirect from the old to the new, without you having to lift a finger.

Now I’ve had a good dig around and was unfortunately unable to discover what type of direct that WordPress applies to the old permalink – but I suspect it is a 301. If anyone knows for sure, let us know in the comments section.

One last thing – this functionality does not exist for Pages, Categories or Tags. The reason for which is beyond me. Answers on a postcard!

Creative Commons images courtesy of tm-tm and Nadya Peek

Comments (5)

  1. Hi :) i’m not a developer but i found that wp use the post id, the numered permalink to identify a post; so if u use nice written permalink u can change it but the post id remains the same. Obliviously all the links system has to be made with default permalink to not get 404, and not with nice permalink. Bye!

  2. This is one of those things I’ve spent months trying to explain to some clients. They don’t get it, so they argue…a lot. It’s good AND BAD.

    This uses a 301 redirect. It is based on a “_wp_old_slug” row within the post_meta table. You CAN add your own to this table to to make it consume additional URLs (say, you’re switching from another platform to WP). However, doing so consumes the string from meta_value whenever it’s used. That means that if you don’t manually prune this table, you can end up with a previous post named ‘blog’ preventing your URLs for buddypress from working correctly. This was a huge problem for a client last year and it took me hours to discover the source of the problem. The fix was to delete the previous “_wp_old_slug” from the postmeta table in order to prevent it from consuming all requests with that four letter word.

    Bottom line: this is EXCELLENT behavior as long as you are keeping tabs on it and aren’t the kind of person to use one-word titles. If you DO use a one-word title, expect things to get ugly when you use that word again later on. Very ugly. ESPECIALLY if you change the URL at some point FROM the one-word slug to a longer slug.

Participate