SQL queries update WordPress URLs

Update site url in wp_options:

UPDATE wp_options 
SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') 
WHERE option_name = 'home' OR option_name = 'siteurl';

Update guid:

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

Update all urls in post content:

UPDATE wp_posts 
SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

Update all urls in meta fields:

UPDATE wp_postmeta 
SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

Leave a Reply

Your email address will not be published. Required fields are marked *

Robbert Vermeulen

Need help from a WordPress expert?

I would love to hear about your project and how I can help you achieve your goals