With WP-CLI, wp core update updates WordPress from the command line, and the --version flag lets you move to a specific version, newer or older. Use it to upgrade, pin a known release, or roll back after a bad update.
For other ways to roll back, including without shell access, see how to downgrade WordPress to a previous version.
WP-CLI Commands to Update or Downgrade WordPress
Run these from the WordPress root directory over SSH (or add --path=/path/to/wordpress). Start by checking what is installed and what is available:
# Show the installed version
wp core version
# Version plus database revision, TinyMCE version and package language
wp core version --extra
# List available updates
wp core check-update
Update to the latest version, or only to the latest minor release of your current branch:
wp core update
wp core update --minor
Update to a specific version:
wp core update --version=7.0.4
Downgrade to a specific version, or reinstall the version you already have:
wp core update --version=6.9.7 --force
Then run the database update routine:
wp core update-db
How the Flags Work
wp core update downloads the release from WordPress.org and replaces the core files. Your themes, plugins and uploads in wp-content, and wp-config.php, are not replaced.
--version=<version> picks the exact release instead of the latest. It also accepts nightly.
--force updates even when the installed version is newer than the requested one. Without it, a request for an older version changes nothing and WP-CLI only reports “WordPress is up to date.”
--minor stays within your current branch, for example from 7.0.2 to 7.0.4 without jumping to 7.1.
--locale=<locale> downloads a specific language package, such as he_IL.
After the files are replaced, WP-CLI removes core files that don’t exist in the target version when checksums for both versions are available.
wp core update-db runs the same database upgrade you would otherwise confirm in the dashboard. On multisite, use wp core update-db --network.
Downgrade WordPress Safely
A downgrade replaces the files, but it does not undo database changes a newer version has already made. Take a backup first so you can restore the exact previous state:
# Back up the database
wp db export before-downgrade.sql
# Downgrade, then verify the core files
wp core update --version=6.9.7 --force
wp core verify-checksums
wp core verify-checksums compares the installed core files with the official checksums from WordPress.org. It reports missing, modified and extra core files, so it catches an incomplete download and also flags altered core files on a hacked site.
Keep a file backup of wp-content as well, because plugins and themes that were updated for the newer version may not work on the older one.
Automatic background updates can move a downgraded site forward again.
Disable automatic WordPress updates until you are ready to upgrade, and plan to return to the latest release soon. Only the latest version of WordPress is officially supported.
FAQs
Common questions about updating WordPress with WP-CLI:
How do I update WordPress to a specific version with WP-CLI?
Run wp core update --version=7.0.4 with the version you want. If that version is older than the one installed, add --force.
Why does wp core update --version not downgrade WordPress?
WP-CLI refuses to install an older version unless you pass --force. Without it, the command changes nothing and only reports "WordPress is up to date."
Do I need to run wp core update-db after updating?
Run it after any core update. If no database changes are needed it does nothing, and if they are, it applies them without waiting for someone to open the dashboard. Use wp core update-db --network on multisite.
How do I upgrade WP-CLI itself?
Run wp cli update. It only works when WP-CLI was installed as a Phar file. If you installed it with Homebrew or another package manager, update it through that package manager.