Skip to content

Instantly share code, notes, and snippets.

@pat-eason
Created November 26, 2014 15:46
Show Gist options
  • Save pat-eason/d2d91d16b026759fccab to your computer and use it in GitHub Desktop.
Save pat-eason/d2d91d16b026759fccab to your computer and use it in GitHub Desktop.
WordPress SQL update
#set variables
SET @oldurl = 'http://oldurl.com';
SET @newurl = 'http://newurl.com';
#update wp_site options
UPDATE wp_options SET option_value = replace(option_value, @oldurl, @newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
#update wp_posts guid
UPDATE wp_posts SET guid = REPLACE (guid, @oldurl, @newurl);
#update wp_posts content
UPDATE wp_posts SET post_content = REPLACE (post_content, @oldurl, @newurl);
#update wp_postmeta
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, @oldurl, @newurl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment