Skip to content

Instantly share code, notes, and snippets.

@x9t9
Created February 1, 2017 00:22
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 x9t9/1c492914a13f4ed7e418db6c2d6322c9 to your computer and use it in GitHub Desktop.
Save x9t9/1c492914a13f4ed7e418db6c2d6322c9 to your computer and use it in GitHub Desktop.
Wordpress Update SQL
/**
To update WordPress options with the new blog location, use the following SQL command:
note that this depends also on your folder structure ( wp in own folder here, not root )
**/
UPDATE wp_newsite_options SET option_value = replace(option_value, 'www.oldnetwork.com/multi', 'www.newsite.com/newsite') WHERE option_name = 'home' OR option_name = 'siteurl';
/**
After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as absolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
**/
UPDATE wp_newsite_posts SET guid = replace(guid, 'www.oldnetwork.com','www.newsite.com/newsite');
/**
If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
**/
UPDATE wp_newsite_posts SET post_content = replace(post_content, 'www.oldnetwork.com/multi', 'www.newsite.com/newsite');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment