As I’ve been doing more and more with the command line being iPad first, I’ve needed to adapt some of my workflows. Previously if I needed a new WordPress plugin but wasn’t able to find it easily in the WordPress admin interface I’d head over to the WordPress.org Plugin repository to download it, then use FTP to upload it to my server.

Sure it worked, but it’s actually fairly slow. Today we’re going to look at two methods to make this whole process faster by leveraging WP CLI or just a plain old SSH shell connection.

Using WP-CLI to Install a WordPress Plugin

We’ll use WooCommerce Product Generator as our example plugin here because it’s old enough that it won’t show up in the WordPress plugin install search. I use this regularly to generate a few hundred products to test for client sites.

To get started, you will need to know the slug of the product you’re looking to find. You can grab this from the plugin repository page for the plugin you want. See the screenshot below to see what I’m talking about.

Getting the slug for the plugin to use in WP-CLI

Once you have the slug for the plugin you have all the information you need for WP-CLI to work.

wp plugin install woocommerce-product-generator

If you want to activate the plugin right away then add --activate to the end of the command and it will be activated after you install it.

Installing a WordPress Plugin from Terminal

Not all WordPress installs will have WP-CLI installed, but that is only a minor hurdle to installing a plugin from the command line.

In this case, you’ll need to long press on the “Download” button to get the location of the file you want to download. If you’re on macOS or Windows, you can right click and then copy the URL of the file for use in your terminal.

Then you can use this command to download the zip file you want.

wget https://downloads.wordpress.org/plugin/woocommerce-product-generator.1.1.1.zip

Next you’ll need to unzip the file with the unzip command.

unzip woocommerce-product-generator.1.1.1.zip

This will give you the plugin folder you want which you can move to the plugin directory in your WordPress install with the mv command.

mv woocommerce-product-generator plugins/

I’ve done these commands from the wp-content directory of my WordPress install because that’s where I’m usually editing my code from or doing Git commands from. You’ll need to change your mv command to match where you are in your directory tree.

One response to “Installing WordPress Plugins From the Command Line”

  1. Curtis McHale Avatar

    This Article was mentioned on curtismchale.ca