Skip to content

Instantly share code, notes, and snippets.

@jhonsore
Last active October 2, 2021 16:54
Show Gist options
  • Save jhonsore/2088db8a28b6a70a3422036d088adb03 to your computer and use it in GitHub Desktop.
Save jhonsore/2088db8a28b6a70a3422036d088adb03 to your computer and use it in GitHub Desktop.
Wordpress update host sql

S0metimes, you start your wordpress website in your localhost. All posts and url's are created with your url. When deploying your application, the url must be updated to the new host.

This queries update the wordpress url to a new url.

UPDATE wp_options SET option_value = 'https://my-new-website' WHERE option_name = 'siteurl';
UPDATE wp_options SET option_value = 'https://my-new-website' WHERE option_name = 'home';
UPDATE wp_posts SET guid = REPLACE (guid, 'http://localhost/my-old-website','https://my-new-website')
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://localhost/my-old-website', 'http://localhost/my-new-website');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://localhost/my-old-website', 'https://my-new-website');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment