WordPress plugin for old Permalink
Posted by paolo on 15 May, 2007
Sometime we change the Permalink structure in our WordPress installation but if we live thanks to search engines that bring most of our readers on our site, we’re gonna lost lot of them that will not find what where they looking for.
So I’ve coded a little WordPress Plugin that, thanks to a db query, will check if the post searched is a post that has an old Permalink Structure.
I don’t know why but in WordPress when you change the Permalink structure (Admin->Options->Permalinks) only the option in the wp_options table is changed, without changing the “guid” field in the wp_posts table, so, thanks to that field and this plugin, we can reach an old post.
Limitation:
- released under GPL, so I can’t take any responsability for any damage et al.;
- it’s based upon Fabrizio Tarizzo’s Old Plinks Redirects Plugin;
- it works in my heavily modified WordPress 2.0.5 (not the latest even in its 2.0 branch) so it may take some modifies to work properly on another installation;
- notable if WordPress is not on the root of the domain it will not work without some little modifies;
- it will not redirect posts’ comments’ feed but we can work on it;
- please don’t use it on a production site, or do it at your own risk;
- even if I’ve changed the priority of add_action() to 0 (zero) I’ve got an “Headers alreay sent error” with another plugin that was echoing a var_dump() between HTML comments (<!– –>);
- I don’t know how much is the Guid field in the wp_posts table is safe and reliable;
- I don’t know if there is already a plugin that does the same thing: I’ve searched but nothing popped. If it exists is a lot better than this.
- If in the meanwhile you’ve changed the categories’ of the post, this plugin will fail miserably.
TODO:
- Now it doesn’t redirect if we already have an ID but we can save a query if we can also exit the plugin’s code when we are in home (is_home()), in category (is_category()) and so on.
Just drop me a line to have a limited (in time) support or leave a comment here.
Download it here, put it in your wp-content/plugins directory, rename it from .PHPS to .PHP and activate it from the Admin and cross the finger.
Posted in Wordpress, plugin | No Comments »



