Sometimes we work for a website with wordpress keeping the development version on sub directory. Say are working for http://www.example.com website and currently it is live and we work for it’s new version in wordpress. So we setup a new wordpress version on new folder so the current development version is http://www.example.com/new
When we are done with all development and uploaded all contents on that new setup that means all media files and contents media urls are targeting with http://www.example.com/new
So when we are going to make the site live we need to do something manually to replace media paths for contents. Or if we directly copy contents from another hosting in that case same things will happen.
For the faster replacement of each media guid, contents media url or other meta values below mentioned 3 mysql query is nice.
Note: After running below code we need to ensure that all wp-contents/uploads folders contents are available as it was on new development directory.
update wp_posts set guid = replace(guid, 'http://www.example.com/new', 'http://www.example.com') update wp_posts set post_content = replace(post_content, 'http://www.example.com/new', 'http://www.example.com') update wp_postmeta set meta_value = replace(meta_value, 'http://www.example.com/new', 'http://www.example.com') update wp_options SET option_value = 'http://www.example.com' WHERE option_name = 'home' OR option_name = 'siteurl';
With this above queries below listed things will happen –
1. Replace all resource or post guid
2. Replace all old media src url to new src url in post contents
3. Replace all meta resource url like image, video or audio etc
4. Replace site home page and siteurl url