Right now my shortlink structure looks something like this:
I would prefer it to look more like this:
Any ideas how I can alter the code to do just this?
Okay, so, as mentioned in my comment to you: altering core files is not a good idea. But here is a plugin solution.
First we're going to create our own rewrite rules that rewrite
Then we can hook into template redirect and see if our query variable is there. If it is, we'll try and get a permalink out of it. If that fails, we'll throw a 404 error. Otherwise, we'll use `wp_redirect' to send folks to the actual post.
Finally, we hook into
As a plugin: https://gist.github.com/1179555
|show 2 more comments|
Aside from @ChristopherDavis's answer, you can also do it in a PHP independent way, using .htaccess. Simply add this rule:
The only problem is, two redirects happen here (instead of 1) — (for example) if user visits
The advantage is, this never breaks! Plugins may break, but this does not.
PS: I use this (short link structure would be