How to Install WordPress Plugins Using WP-CLI

How to Install WordPress Plugins Using WP-CLI

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:

  1. Open the WordPress Installation Folder in CLI
  2. Get the plugin slug
  3. Install Plugin
  4. Activate Plugin
  5. 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_html

2. 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-lab

From 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-lab

The 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-optimize

4. 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-lab

When 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 --activate

5. 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 list

If you only want to check which plugins are active, you can use an additional filter

wp plugin list --status=active

If you want to check plugins that are inactive, you just need to change the filter to inactive

wp plugin list --status=inactive

But 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-lab

When 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 plugin

or

wp help plugin

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...