Wednesday, April 16, 2014

Wordpress updating links in old posts when things change

Changing the Domainname:
Yes, there is some form of "Search and Replace".
To update WordPress options with the new blog location, use the following SQL command:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
After that [...] fix URLs of the WordPress posts and pages [...] stored in database wp_posts table as guid field. [...]
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
And further on:
Use the following SQL commands [sic!] to fix all internal links [...]:
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');

No comments:

Post a Comment

Please Comment Here!

How to backup and download Database using PHP

< ?php $mysqlUserName = 'databaseusername' ; $mysqlPassword = 'databasepassword' ; $mysqlHostNa...