Skip to content

Instantly share code, notes, and snippets.

@tojibon
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tojibon/6b34e4fb7eeb7936b053 to your computer and use it in GitHub Desktop.
Save tojibon/6b34e4fb7eeb7936b053 to your computer and use it in GitHub Desktop.
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