What are Common Commands to Update WordPress Using WP-CLI?

Reading Time: 2 minutes

WP-CLI is a very handy set of commands. You can run anything that you would run in wp-admin on a WordPress site but from the command line. Useful commands which WP-CLI employs to keep WordPress core updated plugins including the default themes which come with WordPress.

To run WP-CLI on Managed WordPress or Managed WooCommerce, you would need to obtain the SSH creds from the manager, by using the terminal or a command line program like Putty. You’ll then log in and change the home to HTML (which is where WordPress is installed). You have to be in this folder for WP-CLI to work.

cd html

Updating WordPress using WP-CLI

To update WordPress to the most current version, you can run this command, where you would replace out the X  value with the current version number or WordPress.

wp core update --version=5.0.x --force

To update WordPress to the most current version which is 5.0.3, run this command:

wp core update --version=5.0.3 --force

When WordPress 5.1 is released in February 2019, the command will be:

wp core update --version=5.1 --force

If an error does show whilst running the wp core update command (e.g., a WordPress update is already in progress in the terminal), a lock option value might be set. You can delete that option value by using this command:

wp option delete core_updater.lock

Version of WordPress using WP-CLI

To verify the version of WordPress that is installed, you can run this command:

wp core version

Updating Themes Using WP-CLI

Once you have updated WordPress, that will mean the default themes need to be updated as well. You can update those themes by using this command:

wp theme update twentysixteen twentyseventeen twentynineteen

In the previous command example, the themes updated would be Twenty Sixteen, Twenty Seventeen, and Twenty Nineteen.

Updating Plugins Using WP-CLI

If Akismet or Jetpack plugins are installed, you can update those two plugins by running either of the following commands:

wp plugin update akismet

wp plugin update jetpack

You can alternatively update both plugins from one command using:

wp plugin update akismet jetpack

Install Classic Editor using WP-CLI

If the site was on an older version of WordPress (such as 4.9.9) and you were updating to 5.0.3, but you wanted to keep using the classic editor and not the new default Gutenberg block editor, you can install and activate either the Classic Editor or Disable Gutenberg plugins.

To install and activate the Classic Editor plugin, you can run this command:

wp plugin install classic-editor --activate

To install and activate the Disable Gutenberg plugin, use:

wp plugin install disable-gutenberg --activate

Using these commands in WP-CLI will make it easier to update WordPress, themes, plugins, and help you to install plugins from the command line without having to update from wp-admin. Managed WordPress and Managed WooCommerce will automatically update WordPress core, plugins and themes which are on WordPress.org.

Avatar for Luke Cavanagh

About the Author: Luke Cavanagh

WooCommerce Specialist at Liquid Web. Devoted husband and Tween wrangler. Synthwave enthusiast. Jerry Goldsmith fan. Doctor Who fan and related gubbins.

Latest Articles

How to Make OpenStack Work for You

Read Article

How to Install MediaWiki on CentOS 7

Read Article

Five Steps to Create a Robots.txt File for Your Website

Read Article

Premium Business Email Pricing FAQ

Read Article

Microsoft Exchange Server Security Update

Read Article