Moving a WordPress Website

WordPress is great don’t get me wrong, but the fact that they don’t seem to think or care that it’s possible that you’ll want to develop on a different domain to the one you finally take live annoys me. Drupal requires almost zero config to take from dev.example.com to just example.com. WordPress on the other hand seems to be a lot of work.

There are a couple of guides in the Codex if you’re looking to move a site, but I thought I’d add a help piece of code (with a warning) that I use every single time.

UPDATE wp_posts SET post_content = replace(post_content,"http://dev.example.com","http://example.com");
UPDATE wp_posts SET guid = replace(guid,"http://dev.example.com","http://example.com");
UPDATE wp_options SET option_value = replace(option_value,"http://dev.example.com","http://example.com");

My warning is to remember to copy any ‘Text’ widgets your site has before proceeding. For some reason if you change the links in a text widget and the new domain length is different to the original it will delete the text widget’s content completely.

Good luck.