Skip to content

Essential WP-CLI Commands for Hosting Support

WP-CLI is an indispensable tool for managing WordPress installations via the command line. It is significantly faster for bulk operations and is essential for troubleshooting issues when the WordPress dashboard is inaccessible.

When migrating a site or changing domains, the first step is updating the core options in the wp_options table.

Terminal window
wp option get siteurl
wp option get home
Terminal window
wp option update home '[https://newurl.tld](https://newurl.tld)'
wp option update siteurl '[https://newurl.tld](https://newurl.tld)'

After updating the URL options, you must run a search and replace on the entire database to fix serialized links in your posts and metadata.

Always perform a dry run first to see how many replacements will be made. Use | tail -1 to see a clean summary.

Terminal window
wp search-replace '[https://oldurl.tld](https://oldurl.tld)' '[https://newurl.tld](https://newurl.tld)' --skip-columns=guid --dry-run | tail -1
Terminal window
wp search-replace '[https://oldurl.tld](https://oldurl.tld)' '[https://newurl.tld](https://newurl.tld)' --skip-columns=guid | tail -1

Use these commands to force-update components or repair a site that has corrupted files or plugin conflicts.

Terminal window
wp plugin update --all --force
wp theme update --all --force

This command fetches a fresh copy of every currently installed plugin or theme from the WordPress repository.

Terminal window
# Reinstall all plugins
wp plugin install $(wp plugin list --field=name) --force
# Reinstall all themes
wp theme install $(wp theme list --field=name) --force

If scheduled events (like backups or publishing) are failing, check the cron event queue.

Using --skip-plugins ensures that a broken plugin doesn’t prevent the command from running.

Terminal window
wp cron event list --skip-plugins

Manually trigger all events that are currently due to run:

Terminal window
wp cron event run --due-now

Use these commands to verify that the core WordPress files have not been modified or corrupted.

Terminal window
wp core verify-checksums

If checksums fail, you can reinstall WordPress core files without affecting your content or database:

Terminal window
wp core download --version=$(wp core version) --force