WordPress stores its configuration in a database table called wp_options. This includes your site name, site URL, admin email, and hundreds of settings added by plugins and themes. WP-CLI lets you read and update these options directly, which is useful when settings are wrong or when you cannot access the WordPress dashboard.
The two most important options
The siteurl and home options control your site's address. If these are set to the wrong URL, WordPress will redirect every request to the wrong domain and the site will be inaccessible. WP-CLI is often the only way to fix this without direct database access.
Command reference
| Command | What it does |
|---|---|
wp option get siteurl | Shows the WordPress site URL |
wp option get home | Shows the WordPress home URL |
wp option get blogname | Shows the site title |
wp option get admin_email | Shows the admin email address |
wp option get <option-name> | Gets the value of any option by name |
wp option update siteurl 'https://example.com' | Sets the site URL |
wp option update home 'https://example.com' | Sets the home URL |
wp option update <option-name> '<value>' | Updates any option value |
wp option list | Lists all options in the database (output is very long, so pipe to grep) |
wp option list | grep <keyword> | Searches option names for a keyword |
wp option delete <option-name> | Deletes an option (use with care) |
Fixing a broken site URL
If your site is redirecting to the wrong domain or showing errors, the siteurl or home option may be set incorrectly.
- Check the current values:
wp option get siteurl
wp option get home
- If they are wrong, update them to the correct URL:
wp option update siteurl 'https://yourcorrectdomain.com'
wp option update home 'https://yourcorrectdomain.com'
- Flush the cache:
wp cache flush
- Test your site in a browser to confirm it is working correctly.
Warning
Updating options directly bypasses WordPress validation. Only update options you are sure about. If unsure, take a database backup first.
Need help?
If you have questions about site options, visit our support page or email hello@smarthost.ie.
Frequently asked questions
My site is redirecting to the wrong domain. Can WP-CLI fix this?
Yes. Run wp option get siteurl and wp option get home to see what they are set to. If they are wrong, update them with wp option update. Then run wp cache flush.
What is the difference between siteurl and home?
siteurl is where WordPress is installed. home is the URL visitors use to reach your site. For most sites they should be the same. If they are different and you are not sure why, they should usually match.
How do I find an option name if I do not know it?
Run wp option list and look through the output, or run wp option list | grep <keyword> to search. Plugin options are often named with the plugin's slug as a prefix.
Last updated: 25 March 2026
