Manage WordPress Plugins with WP-CLI

InMotion Hosting servers have WordPress Command Line Interface (WP-CLI) installed. Therefore, you can install and toggle a WordPress plugin using SSH in lieu of the WordPress dashboard. You may want to activate a newly uploaded plugin. Maybe a recently updated plugin prevents you from logging into your WordPress site. Or WordFence Security notified you that a plugin hasn’t been updated in over a year and you want to uninstall it for security purposes. Regardless of the reason, below we cover how to deactivate, remove, and update a WordPress plugin via WP-CLI.

Deactivate Remove Update

Activate and Deactivate Plugins

  1. SSH into the cPanel account which owns the website.
  2. Use the cd command to enter the domain’s document root, e.g. cd public_html.
  3. Ensure you’re in the correct directory with the following command:
    wp option get home && wp option get siteurl    
    
       https://example.com   
       https://example.com
  4. View the installed plugins for the WordPress website:
    wp plugin list   
    
    +--------------------+----------+--------+---------+  
    | name               | status   | update | version |  
    +--------------------+----------+--------+---------+  
    | akismet            | active   | none   | 4.0.8   |  
    | redirection        | inactive | none   | 3.5     |  
    | wp-piwik           | active   | none   | 1.0.19  |  
    | wp-super-cache     | active   | none   | 1.6.4   |  
    | advanced-cache.php | dropin   | none   |         |  
    +--------------------+----------+--------+---------+
  5. Type the following to activate the plugin, replacing plugin with the plugin name from the wp plugin list:
    wp plugin activate plugin    
    
       Plugin 'plugin' activated.   
       Success: Toggled 1 of 1 plugins.
  6. Type the following to deactivate the plugin but leave it installed:
    wp plugin deactivate plugin    
    
       Plugin 'plugin' deactivated.   
       Success: Deactivated 1 of 1 plugins.
  7. Type the following to activate or deactivate the plugin depending on its former state with a single command:
    wp plugin toggle plugin    
    
       Plugin 'plugin' deactivated.   
       Success: Toggled 1 of 1 plugins.

Remove Plugins

Uninstall Plugins

    Type the following to uninstall a plugin:

    wp plugin uninstall plugin   
    
      Uninstalled and deleted 'plugin' plugin.  
      Success: Uninstalled 1 of 1 plugins.

Delete Plugins

    Type the following to delete a plugin without deactivating or uninstalling it first:

    wp plugin delete plugin   
    
      Deleted 'plugin' plugin.  
      Success: Deleted 1 of 1 plugins

    Note: Whether this fixes an issue better than uninstalling it varies per plugin.

Update Plugins

  1. Type the following to update a plugin:
    wp plugin update plugin   
    
      Plugin updated successfully.  
      Success: Updated 1 of 1 plugins.

You can read more about using WP-CLI in our WP-CLI Education Channel.

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

Was this article helpful? Join the conversation!