Skip to content

Instantly share code, notes, and snippets.

@malkafly
Created February 5, 2019 00:55
Show Gist options
  • Save malkafly/1951e7136460da04fe2dcc72c922d0f8 to your computer and use it in GitHub Desktop.
Save malkafly/1951e7136460da04fe2dcc72c922d0f8 to your computer and use it in GitHub Desktop.
update wordpress url
<?php
$link = mysqli_connect("localhost", "user", "password", "database");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "UPDATE wp_options SET option_value = replace(option_value, 'http://oldserver.com.br', 'http://newserver.com.br') WHERE option_name = 'home' OR option_name = 'siteurl';";
if(mysqli_query($link, $sql)){
echo "feito.";
} else {
echo "ERROR: $sql. " . mysqli_error($link);
}
mysqli_close($link);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment