WP-CLI is a set of commands that can be used very easily. It allows you to run everything in wp-admin on a WordPress site but by using the command line. In order to run WP-CLI on Managed WordPress, you need to first obtain the SSH creds from the manager, with help of terminal or a command-line program like Putty. Then log in and change the home to HTML (where WordPress is installed). To work with WP-CLI you need to be present in this folder.
To update WordPress using WP-CLI
In order to update WordPress to the latest version, you need to run the following command.
Note: You will have to replace the X value with the current version number or WordPress.
wp core update --version=5.0.x --force
For example, in order to update WordPress to the most current version which is 5.0.3, run the following command :
wp core update --version=5.0.3 --force
If you wish to update with the 5.1 version, then your command will be :
wp core update --version=5.1 --force
If any error occurs while running the wp core update command (like WordPress update is already in progress in the terminal), then a lock option value might be set. SO, you can delete that option value by using the following command :
wp option delete core_updater.lock
WordPress version using WP-CLI
Run following command, to verify the version of WordPress that is installed :
wp core version
Updating theme using WP-CLI
After updating WordPress, the next step is to update the default themes as well. By using the following command you can update those themes:
wp theme update twentysixteen twentyseventeen twentynineteen
In the above command, the themes updated would be Twenty Sixteen, Twenty Seventeen, and Twenty Nineteen.
Plugins updation using WP-CLI
If you have Akismet or Jetpack plugins installed, then you can update those two plugins by running either of the following commands :
wp plugin update akismet
wp plugin update jetpack
Alternatively, you can update both plugins using one following command :
wp plugin update akismet jetpack
Installing Classic Editor using WP-CLI
If your site was on an older version of WordPress (like 4.9.9) and you wish to update it to 5.0.3, but at the same time if you want to keep using the classic editor and not the new default Gutenberg block editor, then you can install and activate either the Classic Editor or Disable Gutenberg plugins.
Run the following command, to install and activate the Classic Editor plugin :
wp plugin install classic-editor --activate
Run following command, to install and activate the Disable Gutenberg plugin :
wp plugin install disable-gutenberg --activate
With the use of all these commands in WP-CLI it will become easy for you to update WordPress, themes, plugins, and also helps you to install plugins from the command line without having to update from wp-admin.
Also Read :