Skip to content

Instantly share code, notes, and snippets.

@linuslundahl
Created February 11, 2011 10:32
Show Gist options
  • Save linuslundahl/822189 to your computer and use it in GitHub Desktop.
Save linuslundahl/822189 to your computer and use it in GitHub Desktop.
Change wordpress url in code, when there's no access to phpMyAdmin.
global $wpdb;
$query = "UPDATE $wpdb->posts SET post_content = REPLACE (
post_content,
'http://old.com',
'http://new.com')";
$wpdb->query($query);
$query = "UPDATE $wpdb->posts SET guid = REPLACE (
guid,
'http://old.com',
'http://new.com')";
$wpdb->query($query);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment