Skip to content

Instantly share code, notes, and snippets.

@andrewspear
Created April 2, 2015 15:53
Show Gist options
  • Save andrewspear/16c3d104b2123d42c8e4 to your computer and use it in GitHub Desktop.
Save andrewspear/16c3d104b2123d42c8e4 to your computer and use it in GitHub Desktop.
If you are updating the domain of your website but it's running Wordpress, run the code below to update all the old domain references in the database with new domain references.
UPDATE `wp_posts` SET `guid` = replace(guid, 'http://old.domain.com', 'https://new.domain.com');
UPDATE `wp_posts` SET `post_content` = replace(post_content, 'http://old.domain.com', 'https://new.domain.com');
UPDATE `wp_postmeta` SET `meta_value` = replace(meta_value, 'http://old.domain.com', 'https://new.domain.com');
UPDATE `wp_options` SET `option_value` = replace(option_value, 'http://old.domain.com', 'https://new.domain.com');
UPDATE `wp_comments` SET `comment_content` = replace(comment_content, 'http://old.domain.com', 'https://new.domain.com');
UPDATE `wp_comments` SET `comment_author_url` = replace(comment_author_url, 'http://old.domain.com', 'https://new.domain.com');
UPDATE `wp_commentmeta` SET `meta_value` = replace(meta_value, 'http://old.domain.com', 'https://new.domain.com');
UPDATE `wp_users` SET `user_url` = replace(user_url, 'http://old.domain.com', 'https://new.domain.com');
@andrewspear
Copy link
Author

Tested on Wordpress 4.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment