Skip to content

Instantly share code, notes, and snippets.

@andybeak
Created May 5, 2015 15:02
Show Gist options
  • Save andybeak/33f0632d692a342987a1 to your computer and use it in GitHub Desktop.
Save andybeak/33f0632d692a342987a1 to your computer and use it in GitHub Desktop.
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment