Have you ever wanted to bulk-install or update multiple WordPress plugins in one go?
In this tutorial, we’ll use WP-CLI to install multiple plugins from the command line interface. We’ll show you how to manage your plugins using WP-CLI, such as updating multiple plugins, activate/deactivate plugins and deleting (uninstall) plugins in bulk – all without having to log in to your WordPress site!
Before we get started, let’s discuss a few prerequisites:
- If you’re using WordPress on a shared hosting provider, your host must offer SSH access and have WP-CLI installed. You can check the official WordPress list of supported hosts, but as it so happens all of our recommendations for best WordPress hosting come with WP-CLI pre-installed.
- If you’re hosting WordPress in a VPS or cloud server, we’ll show you how to install WP-CLI in your server, later in this tutorial. (PS: If you want to learn how to install WordPress in a VPS, follow our DigitalOcean tutorial)
- Your OS should be a UNIX-like environment (Linux, OS X, FreeBSD); you must have PHP 5.4+ and WordPress 3.7 or later. Since almost all recommended WordPress hosts will meet these criteria, you’re good to go.
- Finally, this tutorial is not intended for beginners. People familiar with the command-line interface (CLI) and server management should use this tutorial.
Let’s get started.
What is WP-CLI in WordPress?
WP-CLI is a free, open-source project that lets you manage your WordPress site using the command-line interface (CLI). WP-CLI hugely simplifies a lot of WordPress tasks, such as installing WordPress, backing up the database, updating the WordPress core and installing or updating WordPress plugins and themes.
All of this can be done by typing in a few commands in the terminal, without having to log in to your WordPress site. The result? A lot of time saved, less room for error and skyrocketing productivity! Here’s a good primer from WPShout to learn more about WP-CLI.
How to install WP-CLI in a WordPress VPS or Cloud Server?
Users who have installed WordPress in a VPS (such as DigitalOcean), a cloud hosting provider (such as Amazon Web Services (AWS) or Google Cloud), or a managed cloud host (such as CloudWays), can install WP-CLI in their server.
Step 1: Login to your server with the root user. If you don’t have access to the root user, login with a user with read, write and execute permissions in the “/var/www/html” directory.
Step 2: Download the wp-cli.phar file using wget or curl (we’ve used cURL):
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Step 3: Verify that the Phar file is working. Type in the following command, and you should see a similar output:
php wp-cli.phar --info
Step 4: we want to execute WP-CLI from the command line by just typing wp. To do this, we need to make the WP-CLI file executable and move it to the bin directory.
- To make the WP-CLI file executable, type:
chmod +x wp-cli.phar
- Next, move it to the bin directory:
sudo mv wp-cli.phar /usr/local/bin/wp
Step 5: Now we’ll test if WP-CLI is properly executable:
- First, change the working directory to the WordPress installation directory:
- Next, run the following command, and you should see a similar output as shown in the screenshot above.
Caution: Root Access Error in WP-CLI & Solution
Sometimes, when you execute WP-CLI commands as a root user, you might get the following error:
In such a case, simply append –allow-root to the command, and you’re good to go. Here’s an example of a command test whether WP-CLI recognizes the existing WordPress installation.
wp core version --allow-root
Once you have this working, you’re ready to bulk-install plugins.
How to Bulk Install Multiple Plugins in WordPress using WP-CLI
In this section, we’ll show you how to bulk-install multiple plugins in WordPress from the command line interface, using WP-CLI. For reference, keep the official WP-CLI plugin documentation handy.
The basic plugin installation command is as follows:
wp plugin install PLUGIN_NAME
The code to install multiple plugins is: (You can add as many plugins as you need)
wp plugin install PLUGIN_1_NAME PLUGIN_2_NAME PLUGIN_3_NAME
Now, the trick is to figure out the correct name of the plugin. To do this, visit the plugin’s URL page, and copy the URL slug.
- For instance, the Jetpack plugin URL is https://wordpress.org/plugins/jetpack/
- Therefore the plugin name is jetpack
- Similarly, for the Yoast SEO plugin, the URL is https://wordpress.org/plugins/wordpress-seo/
- Therefore the plugin name is wordpress-seo
To install a single plugin, the code is:
wp plugin install jetpack
To install both Jetpack and Yoast SEO, the code is:
wp plugin install jetpack wordpress-seo
(Note that we’ve used –allow-root to ensure that the code runs in our VPS.)
How to Install and Activate Multiple Plugins in WordPress using WP-CLI
By default, the plugins installed by WP-CLI aren’t activated. If you want to activate a plugin immediately after installation, append –activate to the command.
However, we recommend not activating plugins that require onboarding configuration (such as caching and backup plugins), directly from WP-CLI.
Plugins that don’t require onboarding configuration such as Insert Headers and Footers can be activated from the command line:
wp plugin install insert-headers-and-footers --activate
That’s it! Now you know how to bulk-install and activate multiple plugins using WP-CLI. In the next section, we’ll teach you plugin management using WP-CLI.
Bulk Plugin Management in WP-CLI in WordPress
You can use WP-CLI for a variety of plugin management tasks such as:
- Listing the number of installed plugins
- Multiple plugin activation/deactivation
- Updating and deleting plugins in bulk
How to List Number of Installed Plugins in WordPress using WP-CLI
This command displays the number of installed plugins in your WordPress site in a table, including vital information such as the plugin’s activation status, current version and available updates (if any).
wp plugin list
How to Activate or Disable Multiple Plugins at once using WP-CLI
Similar to the plugin installation command, add the names of plugins you want to activate or deactivate and press return.
wp plugin activate PLUGIN_1_NAME PLUGIN_2_NAME
Thus the command to activate Yoast SEO and Jetpack (assuming they are installed) is:
wp plugin activate wordpress-seo jetpack
Similarly, the command to deactivate (or disable) both plugins is:
wp plugin deactivate wordpress-seo jetpack
Alternately, you can disable all active plugins in your WordPress site with this one command:
wp plugin deactivate --all
How to Bulk-Update Multiple Plugins in WordPress using WP-CLI
Another beneficial application of WP-CLI is its ability to bulk-update all installed plugins in your WordPress site. The command is:
wp plugin update --all
If you’re trying WP-CLI for the first time, we would suggest doing so in a staging server or a new WordPress instance. Once you’re familiar with the tool, you can start using it in your live site.
Hope you’ve learned something new from this tutorial. Have you used WP-CLI before? What are your favourite tricks?