Wednesday, 24 July 2013

Transfering wordpress - sql query

When ever we transfer the wordpress site either to local to live or vice-versa. We need to changes the url of the site in the db as wordpress store absolute path of each url.
Important Sql query for the wordpress
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
 
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
 
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
 
UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="http://www.oldsiteurl.com', 'src="http://yourcdn.newsiteurl.com');
 
UPDATE wp_posts SET  guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://yourcdn.newsiteurl.com') WHERE post_type = 'attachment';
 
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.oldsiteurl.com','http://www.newsiteurl.com');

No comments :

Post a Comment