pierrebalian
9/25/2017 - 5:45 PM

Useful SQL Queries

Useful SQL Queries

//Change Site URL and Home url

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

//Fix URL in content

UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');

//Change Image Paths only

UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="http://www.oldsiteurl.com', 'src="http://yourcdn.newsiteurl.com');

//Change all content from one author to another

UPDATE wp_posts SET post_author = 'new-author-id' WHERE post_author = 'old-author-id';