Quick & Easy WordPress Update with WP-CLI

If you manage multiple WordPress websites, it may be difficult to manually update each WordPress website, plugins and themes in their respective WordPress Admin.

Besides that, you may also run the risk of your web server timing out while the update is in progress, throwing everything into disarray.

The solution to this is to use WP-CLI, which is a command line interface to quickly update your WordPress websites. WP-CLI is extremely powerful and it has various features which allows you to administer your WordPress websites but today we will be focusing on the update aspect.

Before you proceed further, make sure that you have SSH access, WP-CLI is supported in your server and you have taken a backup of your WordPress website.

Then, make sure you are in your WordPress directory with this SSH command:-

cd public_html

WordPress Version Update

To update your WordPress version, run this command:-

wp core update

You should see something like this:-

Updating to version X.X.X (en_US)...
Downloading update from https://downloads.wordpress.org/release/wordpress-X.X.X-partial-0.zip...
Unpacking the update...
Success: WordPress updated successfully.

If you run a WordPress Multisite, you should also run this command to update the database each of your sub-site once the above update is completed:-

wp core update-db --network

WordPress Plugins Update

To update your plugins, first list them with this command:-

wp plugin list

You should see something like this:-

| name                   | status   | update    | version  |
| amp                    | active   | none      | X.X.X    |
| coblocks               | active   | available | X.X.X    |
| disqus-comment-system  | active   | none      | X.X.X    |
| litespeed-cache        | active   | none      | X.X.X    |
| seo-by-rank-math       | active   | available | X.X.X.X  |
| google-site-kit        | active   | none      | X.X.X    |
| tawkto-live-chat       | active   | none      | X.X.X    |
| wp-search-with-algolia | active   | none      | X.X.X    |
| advanced-cache.php     | dropin   | none      |          |

Under the update section, you will see either available which means a plugin update is available or none which means there are no new update.

So if I am going to update the coblocks plugin, I will run this command:-

wp plugin update coblocks

And you will see something like this:-

Enabling Maintenance mode...
Downloading update from https://downloads.wordpress.org/plugin/coblocks.X.X.X.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Disabling Maintenance mode...
Success: Updated 1 of 1 plugins.
| name     | old_version | new_version | status  |
| coblocks | X.X.X       | X.X.X       | Updated |

You can also update all plugins with available update by running this command:-

wp plugin update --all

WordPress Themes Update

It is generally recommended to only have two themes, one being your active theme and the other being WordPress’s official theme (just keep one of those is enough for troubleshooting purpose in case you face any theme related issues).

As such, you can go ahead and update all WordPress themes with this command:-

wp theme update --all
James Lee
James Lee

James Lee, a seasoned leader with 15+ years in the tech industry, leverages his Cloud expertise to drive innovative solutions and exceptional customer experiences. He identifies growth opportunities through keen market insights and user behavior analysis, navigating the complexities of the Cloud landscape. A skilled communicator and collaborator, James thrives on exceeding expectations and leading teams to deliver impactful products.

Leave a Reply

Your email address will not be published. Required fields are marked *