Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Replacing media urls on WordPress
<?php
/*
When you are done with all development and uploaded all contents on a development setup that means all media files and
contents media urls are targeting with http://www.example.com/dev your development site.
You can replace all resource and post links to your live site with below written codes in php.
You just need to execute the code with wp query.
Author: Jewel Ahmed
Author Url: http:www.codeatomic.com
*/
update wp_posts set guid = replace(guid, 'http://www.example.com/dev', 'http://www.example.com')
update wp_posts set post_content = replace(post_content, 'http://www.example.com/dev', 'http://www.example.com')
update wp_postmeta set meta_value = replace(meta_value, 'http://www.example.com/dev', 'http://www.example.com')
update wp_options SET option_value = 'http://www.example.com' WHERE option_name = 'home' OR option_name = 'siteurl';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment