WP-CLI is a command line interface tool where you can execute commands related to your WordPress website without the need to log in from the web browser to the back office. This is a useful option because sometimes you may need to perform for example mass actions.

Installing plugin from wordpress.org repository.

To install new plugin from the wordpress.org repository, just run the command given below in your terminal. In my example it will install and activate the bbPress plugin:

wp plugin install bbpress --activate

As a result you should receive a table similar to the one below:

Installing bbPress (2.5.9)
Downloading install package from https://downloads.wordpress.org/plugin/bbpress.2.5.9.zip...
Using cached file '/home/vagrant/.wp-cli/cache/plugin/bbpress-2.5.9.zip'...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Activating 'bbpress'...
Plugin 'bbpress' activated.
Success: Installed 1 of 1 plugins.

Installing development version of plugin from wordpress.org repository.

Similarly run the command given below. Note that this time there is added –version=dev element you should use. Please note that the development versions are often not stable and it’s not recommended to use such on production websites.

wp plugin install bbpress --version=dev

As a result you should receive such summary:

Installing bbPress (Development Version)
Downloading install package from https://downloads.wordpress.org/plugin/bbpress.zip...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Success: Installed 1 of 1 plugins.

Installing the plugin from a local .zip file already uploaded onto your server.

Assuming that you have received the plugin in a .zip file which is ready to be installed on your WordPress based website from the developer or maybe you have created your own, you can also install it from command line.

wp plugin install ../my-plugin.zip

In a result if everything is fine you will receive such summary:

Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Success: Installed 1 of 1 plugins.

Installing the plugin from a .zip file located on a remote server.

Some developers, especially in case of commercial plugins are not putting them into the wordpress.org repository. You can of course use the option mentioned above and download the .zip file from the link provided, upload it onto your server and install but.. you can also do this directly which will save you the fuss with uploading the .zip file. Here’s how.

wp plugin install https://some-server.com/my-plugin.zip

Again if successful you should receive such summary:

Downloading install package from https://some-server.com/my-plugin.zip

Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Success: Installed 1 of 1 plugins.

Updating the plugin from a remote server

Ok, so after you have installed the plugin from a remote server, you will not be able to use the functionality to automatically update it since it’s not in the wordpress.org repository. Right, but.. you can run updates similarly from the link provided by the developer. Just run the command given below.

wp plugin install https://some-server.com/my-plugin.zip

You guessed it, here’s summary:

Downloading install package from https://some-server.com/my-plugin.zip
Unpacking the package...
Installing the plugin...
Plugin updated successfully
Success: Installed 1 of 1 plugins.

Forcefully re-install all installed plugins

Last but not least as we are on the topic of installing plugins. There might be a need to reinstall them all. Again through the dashboard it’s a pretty laborious process but here. One command to rule them all.

wp plugin install $(wp plugin list --field=name) --force

In our summary is only one plugin present but in your case the list might be significantly longer.

Installing Akismet (3.1.11)
Downloading install package from https://downloads.wordpress.org/plugin/akismet.3.1.11.zip...
Unpacking the package...
Installing the plugin...
Removing the old version of the plugin...
Plugin updated successfully
Success: Installed 1 of 1 plugins.

Great! You now know how to install and reinstall plugins without logging into your WordPress dashboard.

If you like this post and you consider it to be usefull, please give it a heart and leave a comment. It will encourage me to post more often.

Author

I’m Michael , a tech geek. Join me on the journey through interwebs to find latest news, tips and hints.

Write A Comment