WordPress Updates with WP-CLI

Most people do plugin, theme and WordPress core updates via the WordPress Update page.

But if you are managing multiple sites, you might find it’s easier for you if you use the command line.

Once you are logged into the site via SSH (a secure encrypted text-based terminal for accessing your web hosting account’s files and many Linux commands), then many WordPress command line functions are available to you.

One requirement: you have to be using a website hosting company that gives you access to the command line, via SSH. I recommend SiteGround for hosting almost all sites.

WP-CLI works in your WordPress folder (for most people, that’s the public_html folder, aka the www folder). It also works in WordPress sub-folders, e.g. ~/www/wp-content/

cd ~/www

Plugin and Themes Updates

Get a list of plugins your site uses:

wp plugin list

Plugins that need updates:

wp plugin list --update=available

Update all plugins:

wp plugin update --all 

Update all plugins excluding WooCommerce (or any other plugin that itself has plugins, and therefore you should update all the plugins-plugins first and then update the main plugin). Substitute the name of the plugin, from the “wp plugin list” command:

wp plugin update --all --exclude=woocommerce

Updating Your Themes

wp theme list
wp theme update --all

Updating WordPress Core from SSH

wp core update

What Other WP-CLI Commands Are Available?

wp help

That shows you a list of commands, and a brief description. You can then get help on any of those commands

wp help core

Many of the WP-CLI commands have several levels, and several parameters. For example:

wp user create bob bob@example.com --role=author

So use “wp help user create” to see what the available parameters and options are for the “wp user create” command.

If you simply type the command without the required parameters, you will get a brief usage prompt.

wp user create
usage: wp user create [--role=] [--user_pass=] [--user_registered=] [--display_name=] [--user_nicename=] [--user_url=] [--nickname=] [--first_name=] [--last_name=] [--description=] [--rich_editing=] [--send-email] [--porcelain]

Some plugins have their own WP-CLI access, check the plugin’s documentation or the “wp help” list.

The help documents are displayed using “less” (the Linux command for paging through a text document, at least on some flavors of Linux; your flavor of Linux might use “more”), PgUp and PgDn work, as does searching for text with the “/” key, or getting help on using less by pressing the “h” key. Exit by pressing the “q” key.






Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.