The plugin and theme subcommands let you manage plugins and themes, respectively. Among others, you can install, (de)activate, delete and and update individual plugins and themes.

Both subcommands take the same options. For instance, you can list all installed plugins using wp plugin list and you can list all installed themes via wp theme list. As we don’t really want to go over the same subcommands twice we will just look at plugins – just remember that managing themes works just the same.

Listing and deleting plugins

If you have just installed WordPress you should have two plugins: Akismet and Hello Dolly. Both are inactive by default, and many users delete the plugins after installing WordPress. Let’s list and remove the plugins:

$ wp plugin list
+---------+----------+--------+---------+
| name    | status   | update | version |
+---------+----------+--------+---------+
| akismet | inactive | none   | 4.1.3   |
| hello   | inactive | none   | 1.7.2   |
+---------+----------+--------+---------+

$ wp plugin delete akismet
Deleted 'akismet' plugin.
Success: Deleted 1 of 1 plugins.

$ wp plugin delete hello
Deleted 'hello' plugin.
Success: Deleted 1 of 1 plugins.

Unfortunately, it is not possible to delete both plugins in one go. Two remove both plugins you need to run two separate wp plugin delete commands. However, if you are removing the plugins as part of a customisation script then you can simply add the commands to the script.

Searching for plugins (or themes)

The plugin search subcommand lets you search the wordpress.org plugin directory. By default, the output includes the plugin’s name, slug and user rating. However, there are dozens of other fields that can be displayed – all the available options are listed on the plugin search page. You just need to add the --fields option followed by a comma-separated list of field names:

$ wp plugin search "two factor authentication" --fields=slug,last_updated,rating,tested --per-page=15
Success: Showing 15 of 118 plugins.
+------------------------------------+------------------------+--------+--------+
| slug                               | last_updated           | rating | tested |
+------------------------------------+------------------------+--------+--------+
| wordfence                          | 2020-02-12 4:18pm GMT  | 96     | 5.3.2  |
| two-factor-authentication          | 2020-02-13 10:41pm GMT | 90     | 5.3.2  |
| miniorange-2-factor-authentication | 2020-02-22 11:14pm GMT | 88     | 5.3.2  |
| jetpack                            | 2020-02-21 11:22am GMT | 78     | 5.3.2  |
| two-factor                         | 2020-02-12 7:41pm GMT  | 98     | 5.3.2  |
| duo-wordpress                      | 2019-05-17 6:25pm GMT  | 74     | 5.2.5  |
| wp-simple-firewall                 | 2020-02-25 12:56pm GMT | 98     | 5.3.2  |
| rublon                             | 2019-05-23 10:01am GMT | 84     | 5.2.5  |
| unloq                              | 2020-02-24 9:27am GMT  | 88     | 4.9.13 |
| 2fas                               | 2020-01-27 12:26pm GMT | 72     | 5.3.2  |
| keyy                               | 2019-10-17 11:57am GMT | 92     | 5.3.2  |
| wp-cerber                          | 2020-02-12 3:28pm GMT  | 98     | 5.3.2  |
| wordpress-2-step-verification      | 2020-01-02 4:03pm GMT  | 86     | 5.3.2  |
| wordfence-login-security           | 2020-01-13 7:20pm GMT  | 94     | 5.3.2  |
| application-passwords              | 2020-01-08 10:56pm GMT | 92     | 5.3.2  |
+------------------------------------+------------------------+--------+--------+

The search feature is mostly useful if you know what you are looking for. Searches can yield a large number of results, and some SEO-aware plugin developers skew the results by using very long plugin names that contain as many keywords as possible. That said, you can retrieve a lot of useful information.

Installing plugins (or themes)

In any case, let’s install and activate the Two-Factor plugin. To do so, you need to enter the plugin’s slug, a URL to a remote zip file or the path to a local zip file. It is usually easiest to enter the slug:

$ wp plugin install two-factor
Installing Two-Factor (0.5.1)
Downloading installation package from https://downloads.wordpress.org/plugin/two-factor.zip...
Using cached file '/home/example/.wp-cli/cache/plugin/two-factor-0.5.1.zip'...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Success: Installed 1 of 1 plugins.

$ wp plugin activate two-factor
Plugin 'two-factor' activated.
Success: Activated 1 of 1 plugins.

$ wp plugin status two-factor
Plugin two-factor details:
    Name: Two Factor
    Status: Active
    Version: 0.5.1
    Author: Plugin Contributors
    Description: Two-Factor Authentication using time-based one-time passwords, Universal 2nd Factor (FIDO U2F), email and backup verification codes.

Updating plugins (or themes)

The command to update plugins is – you guessed it – plugin update. To update all plugins you can run the command plugin update --all. Or, you can update an individual plugin by specifying the plugin’s slug:

[example@cpweb6-premium public_html]$ wp plugin update two-factor
Success: Plugin already updated.

And finally, if you just want to check if there are any updates then you can add the --dry-run option:

$ wp plugin update --all --dry-run
No plugin updates available.