andybeak
5/5/2015 - 3:02 PM

Update Wordpress posts when moving domains (e.g.: deploying)

Update Wordpress posts when moving domains (e.g.: deploying)

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE instr(meta_value, 'http://www.olddomain.com') > 0;

UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE instr(guid, 'http://www.olddomain.com') > 0;

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE instr(post_content, 'http://www.olddomain.com') > 0;