Moving Your WordPress Installation? Consider This!

There are some great articles and tutorials on how to move your WordPress installation for all manner of user levels. They range from the basic to the detailed or for more advanced users.

But one thing these guides have failed to mention if you use the built-in upload facility – watch your absolute server paths.

What the frak is an “Absolute Server Path”

The absolute server path is the full path to a file or folder. More about paths. For example a jpeg file name “just-a-picture.jpg” is stored here: wp-content/uploads/just-a-picture.jpg.

The absolute server path could look like this:

/home/username/public_html/wp-content/uploads/2007/03/just-a-picture.jpg

This value is what WordPress saves every time you upload an attachment inside the following post meta keys:

  • _wp_attached_file
  • _wp_attachment_metadata

While this doesn’t really affect what you see on your website, it does affect the uploads admin page. Instead of seeing a thumbnail, you’ll see the full image.
And unless you want to upload all the images again, then you’re screwed.

Okay so I am exaggerating. You just have a bit more work to do.

So what do I do?

Before transferring your database over to your new server, open your database backup in a text editor and change all instances of the old server path to the new one with the search facility.

Or you could use the tool mentioned here to do a global search and replace for the absolute server paths.

I ended up making a plugin to help fix 1000+ attachments for my friend’s website. With better than dial-up internet speed, it took about a minute each to fix thumbnails and attachments.

So I’m releasing the Fix Attachments plugin for use as a last resort in case the two options I mentioned above don’t work for you.

Remember, have an unaltered backup of your database handy in case anything goes wrong. The plugin worked fine in my case but it may not work in yours and you WILL want to restore your database.