Since we previously tried installing WP-CLI on a Linux server, this time we will discuss how to install WordPress plugins using WP-CLI.
How to Install WordPress Plugins Using WP-CLI
Before going further, this tutorial will only cover how to install plugins that are already in the WordPress repository. Plugins that use zip files will be discussed in the next article.
Let's get started. There are several steps you need to take to install WordPress plugins using WP-CLI, including:
- Open the WordPress Installation Folder in CLI
- Get the plugin slug
- Install Plugin
- Activate Plugin
- Check Plugin Status
1. Open the WordPress Installation Folder in CLI
Next, you can open your WordPress installation folder. For example, if you are using cPanel, the WordPress installation folder is usually located inside the public_html folder. However, since this tutorial does not use cPanel, the installation folder location is different.
If your installation folder is in public_html, you can use the command cd to open the installation folder
cd public_html2. Get the Plugin Slug
To get the plugin slug, you can use the command plugin search in the terminal
wp plugin search <nama-plugin>For example, if you want to install the plugin Performance Lab, you can use the following command
wp plugin search performance-labFrom that search, the results will look something like this
However, if you still cannot find the plugin you want to install, you can also get the slug from the plugin page on wordpress.org.
For example, for the plugin Performance Lab you can access it from the page https://wordpress.org/plugins/performance-lab/, which means the slug used is performance-lab
3. Install Plugins Using WP-CLI
Once you are inside the WordPress installation folder where you want to add the plugin, you can install the plugin with the following command
wp plugin install <slug plugin>For example, to install the plugin Performance Lab, you can change the command to look like this
wp plugin install performance-labThe output when you successfully install a plugin will look something like this
If you want to install more than one plugin, you can add several slugs at once, for example
wp plugin install litespeed-cache w3-total-cache wp-optimize4. Activate Plugins Using WP-CLI
Finally, to activate the plugin, you can use the command plugin activate after the plugin is installed
wp plugin activate <slug-plugin>For example, to activate the Performance Lab plugin, you can use the following command
wp plugin activate performance-labWhen the plugin activation process is successful, you will get an output that looks something like this
Additionally, you can also install and activate a plugin using a single line command just by adding --activate when installing the plugin, for example
wp plugin install wp-fastest-cache --activate5. Check Plugin Status
If you are curious about whether the plugin is actually installed and active or not, you might think of accessing the WordPress dashboard page, which is easier.
However, you can actually check the plugin status using WP-CLI. You just need to run the following command to check the status of all plugins installed on your WordPress site
wp plugin listIf you only want to check which plugins are active, you can use an additional filter
wp plugin list --status=activeIf you want to check plugins that are inactive, you just need to change the filter to inactive
wp plugin list --status=inactiveBut if you only want to check the status of the plugin you just installed, for example Performance Lab, you can use the command status
wp plugin status performance-labWhen using the status command, you will get an output that looks something like this
That is the easy way to install WordPress plugins using WP-CLI. If you are curious about the commands that can be used to manage plugins, you can run the following command
wp pluginor
wp help plugin
COMMENTS
Loading...