Resolving WordPress Migration Issue

I’m posting this for the benefit of anyone who experiences a similar problem to mine when moving WordPress from a directory into the web’s root directory.

What happened was that many links and pictures, some placed in there by plugins, others simply links that were typed in, had failed.

I realised that although I’d followed the migration instructions, a lot of things were left poorly sorted. A quick run through of all the tables showed where values were left incorrectly set. To fix this I wrote the following SQL statements and applied them to my database:

update wp_posts set guid = replace(guid,”/wordpress”,””);

update wp_postmeta set meta_value = replace(meta_value,”/wordpress”,””);

update wp_options set option_value = replace(option_value,”/wordpress”,””);

update wp_posts set post_content = replace(post_content,”/wordpress”,””);

These worked a treat.

To use this yourself I’ve done a version below that you can edit – simply replace $$$olddir$$$ with your old directory name (in my case wordpress) and replace $$$newdir$$$ with your new directory name. If your new directory is the root, remove the / at the beginning of each $$$newdir$$$ – see my example above.

A couple of warnings though – first take a backup of your database! Then think carefully – if you don’t know what you’re doing you may well be advised in seeking someone out who does.
update wp_posts set guid = replace(guid,”/$$$olddir$$$”,”/$$$newdir$$$”);

update wp_postmeta set meta_value = replace(meta_value,”/$$$olddir$$$”,”$$$newdir$$$”);

update wp_options set option_value = replace(option_value,”/$$$olddir$$$”,”$$$newdir$$$”);

update wp_posts set post_content = replace(post_content,”/$$$olddir$$$”,”$$$newdir$$$”);

Good luck and have fun!

Shiny new things!

Well… kind of. You won’t see much difference, but I’ve just upgraded the software for the blog to v2.0.1 – in reality it makes the blog a fair bit easier for me to use, but won’t make much of a difference to you except that with a bit of luck you’ll see better updates. The theme’s changed too, so the colours and layout may look a little different, but all the functions remain the same.
Of course, my trip’s over now, so the updates on here won’t be so frequent. However, there’s the background stuff I promised, and then there’ll be information and updates on my sprinting and hillclimbing this year. Within a short while I’m also hoping to sort out the upload of some pictures from the holiday. But there’s a lot to get through… I managed some 2000 photos in two months!