Skip to content

Instantly share code, notes, and snippets.

@raster
Created March 13, 2013 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raster/5152274 to your computer and use it in GitHub Desktop.
Save raster/5152274 to your computer and use it in GitHub Desktop.
WordPress URL Changer
/* update all post permalinks */
update wp_posts
set guid = REPLACE(guid, 'http://oldsite.com', 'http://newsite.com')
where guid LIKE '%http://oldsite.com%';
/* update all post content */
update wp_posts
SET post_content = REPLACE(post_content, 'http://oldsite.com', 'http://newsite.com')
where post_content LIKE '%http://oldsite.com%';
/* update all post meta */
update wp_postmeta
SET meta_value = REPLACE(meta_value, 'http://oldsite.com', 'http://newsite.com')
where meta_value LIKE '%http://oldsite.com%';
/* update all options */
update wp_options
set option_value = REPLACE(option_value, 'http://oldsite.com', 'http://newsite.com')
where option_value LIKE '%http://oldsite.com%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment