Skip to content

Instantly share code, notes, and snippets.

@alexleone
Last active February 4, 2020 16:11
Show Gist options
  • Save alexleone/93db97e7c102f6dfd4dd53e4d9058e56 to your computer and use it in GitHub Desktop.
Save alexleone/93db97e7c102f6dfd4dd53e4d9058e56 to your computer and use it in GitHub Desktop.
Use the WP CLI to update a wordpress site url, home url, and the DB references.
# Note the current urls to later be used in DB update
# use the flag --allow-root if only have a root user
wp option get siteurl
wp option get home --allow-root
wp option update home 'https://example.com'
wp option update siteurl 'https://example.com'
# Search and replace all the old urls to reference the new one
wp search-replace 'http://example.test' 'http://example.com'
# Restart webserver
service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment