Learn How to Bulk-Install and Manage WordPress Plugins with WP-CLI
Are you tired of manually installing or updating multiple WordPress plugins? WP-CLI is a free, open-source project that simplifies WordPress tasks by allowing you to manage your site using the command-line interface (CLI). In this tutorial, we’ll show you how to use WP-CLI to bulk-install and manage your WordPress plugins, including activating/deactivating and deleting them in bulk, all without logging in to your WordPress site.
Before we dive in, here are a few prerequisites:
– Your host must offer SSH access and have WP-CLI installed. Check the official WordPress list of supported hosts, or consider one of our recommended WordPress hosts that come with WP-CLI pre-installed.
– Your OS should be a UNIX-like environment (Linux, OS X, FreeBSD), and you must have PHP 5.4+ and WordPress 3.7 or later.
– This tutorial is not intended for beginners. People familiar with the command-line interface (CLI) and server management should use this tutorial.
What is WP-CLI in WordPress?
WP-CLI is a powerful tool that simplifies WordPress tasks such as installing WordPress, backing up the database, updating the WordPress core, and installing or updating WordPress plugins and themes. By typing a few commands in the terminal, you can save time, reduce errors, and increase productivity without logging in to your WordPress site. Learn more about WP-CLI from WPShout.
How to Install WP-CLI in a WordPress VPS or Cloud Server
If you’re hosting WordPress in a VPS or cloud server, you can install WP-CLI on your server. Here’s how:
Step 1: Login to your server with the root user or a user with read, write, and execute permissions in the “/var/www/html” directory.
Step 2: Download the wp-cli.phar file using 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 by typing:
php wp-cli.phar –info
Step 4: Make the WP-CLI file executable and move it to the bin directory:
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Step 5: Test if WP-CLI is properly executable by changing the working directory to the WordPress installation directory and running the following command:
Note: If you get a root access error, append –allow-root to the command.
How to Bulk-Install Multiple Plugins in WordPress using WP-CLI
Now that you have WP-CLI installed, let’s learn how to bulk-install multiple plugins in WordPress from the command line interface. Here’s the basic plugin installation command:
wp plugin install PLUGIN_NAME
To install multiple plugins, use this code (you can add as many plugins as you need):
wp plugin install PLUGIN_1_NAME PLUGIN_2_NAME PLUGIN_3_NAME
To figure out the correct name of the plugin, visit the plugin’s URL page and copy the URL slug. For example, the Jetpack plugin URL is “https://wordpress.org/plugins/jetpack/”, so the plugin name is “jetpack”. Similarly, the Yoast SEO plugin URL is “https://wordpress.org/plugins/wordpress-seo/”, so the plugin name is “wordpress-seo”.
To install a single plugin, use this code:
wp plugin install jetpack
To install both Jetpack and Yoast SEO, use this code:
wp plugin install jetpack wordpress-seo –allow-root
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
How to Manage Plugins in Bulk with WP-CLI in WordPress
WP-CLI can also help you manage your plugins in bulk. Here are a few examples:
– To list the number of installed plugins in your WordPress site, use this command:
wp plugin list
– To activate or deactivate multiple plugins at once, use these commands:
wp plugin activate PLUGIN_1_NAME PLUGIN_2_NAME
wp plugin deactivate PLUGIN_1_NAME PLUGIN_2_NAME
wp plugin deactivate –all
– To update all installed plugins in your WordPress site, use this command:
wp plugin update –all
WP-CLI is a powerful tool that can save you time and increase productivity when managing your WordPress site. If you’re new to WP-CLI, we recommend trying it out on a staging server or a new WordPress instance before using it on your live site. We hope you found this tutorial helpful. Have you used WP-CLI before? What are your favorite tricks?