Skip to main content

Plugin Installation & Updates

Overview

Plugin management is one of WP-CLI's most powerful features. Install, update, and manage WordPress plugins instantly from the command line—perfect for automation, bulk operations, and emergency maintenance.

Understanding Plugin Management

WP-CLI provides complete control over WordPress plugins without touching wp-admin. You can:

  • Install plugins from WordPress.org, ZIP files, or URLs
  • Update plugins individually or in bulk
  • Manage versions with precision
  • Automate deployments across multiple sites
  • Troubleshoot when wp-admin is broken

Installing Plugins

Install from WordPress.org Repository

# Install a plugin by slug
wp plugin install contact-form-7

# Install and activate immediately
wp plugin install woocommerce --activate

# Install specific version
wp plugin install elementor --version=3.16.0

How it works:

  • WP-CLI downloads the plugin from WordPress.org
  • Extracts it to wp-content/plugins/
  • Optionally activates it with --activate

Install from ZIP File

# Install from local ZIP file
wp plugin install /path/to/plugin.zip --activate

# Install premium plugin
wp plugin install ./premium-plugins/gravityforms.zip --activate

Use cases:

  • Premium plugins not in WordPress.org
  • Custom-developed plugins
  • Plugin backups during migrations

Install from URL

# Install from remote URL
wp plugin install https://downloads.wordpress.org/plugin/akismet.5.3.zip

# Install from GitHub release
wp plugin install https://github.com/user/plugin/releases/download/v1.0/plugin.zip --activate

# Install from private server
wp plugin install https://secure.example.com/plugins/custom-plugin.zip
Private Plugin Distribution

Store premium plugins on a private server or S3 bucket and install via URL for automated deployments.

Bulk Plugin Installation

# Install multiple plugins at once
wp plugin install contact-form-7 wordfence updraftplus --activate

# Install agency baseline stack
wp plugin install \
elementor \
woocommerce \
yoast-seo \
wordfence \
wp-mail-smtp \
--activate

Time savings: Install 10 plugins in ~30 seconds vs. 10+ minutes in wp-admin.

Updating Plugins

Update Individual Plugins

# Update a specific plugin
wp plugin update woocommerce

# Update to specific version
wp plugin update elementor --version=3.16.0

# Dry run (preview without applying)
wp plugin update yoast-seo --dry-run

Bulk Plugin Updates

# Update all plugins
wp plugin update --all

# Update all with dry run first
wp plugin update --all --dry-run

# Update all quietly (suppress output)
wp plugin update --all --quiet
Always Backup First

Before running --all updates, backup your database:

wp db export backup-$(date +%Y%m%d).sql
wp plugin update --all

Update Excluding Specific Plugins

# Update all except specific plugins
wp plugin list --field=name | grep -v "woocommerce\|elementor" | xargs wp plugin update

Advanced Installation Options

Force Reinstall

# Force reinstall to fix corrupted files
wp plugin install contact-form-7 --force

# Force reinstall and activate
wp plugin install yoast-seo --force --activate

Use cases:

  • Plugin files corrupted
  • Partial update failed
  • Need to reset plugin to default state

Install with Custom Activation Network

For WordPress Multisite:

# Install and network-activate
wp plugin install wordfence --activate-network

# Install on specific subsite
wp plugin install woocommerce --activate --url=shop.example.com

Checking Plugin Information

List Installed Plugins

# List all plugins
wp plugin list

# List with specific fields
wp plugin list --fields=name,status,version,update

# List only active plugins
wp plugin list --status=active

# List plugins needing updates
wp plugin list --status=update-available

Example output:

+-------------------+--------+---------+--------+
| name | status | version | update |
+-------------------+--------+---------+--------+
| akismet | active | 5.3 | none |
| contact-form-7 | active | 5.8 | none |
| woocommerce | active | 8.2.0 | 8.3.0 |
+-------------------+--------+---------+--------+

Get Plugin Details

# Get detailed plugin information
wp plugin get woocommerce

# Get specific field
wp plugin get woocommerce --field=version

# Check plugin path
wp plugin path woocommerce

Check for Updates

# Check which plugins have updates available
wp plugin list --update=available

# Get update version
wp plugin get elementor --field=update_version

Real-World Scenarios

Scenario 1: New Site Setup

#!/bin/bash
# setup-plugins.sh - Automate plugin installation for new sites

# Essential plugins
wp plugin install \
contact-form-7 \
wordfence \
updraftplus \
wp-mail-smtp \
--activate

# SEO and performance
wp plugin install \
yoast-seo \
w3-total-cache \
--activate

# E-commerce (if needed)
wp plugin install woocommerce --activate

echo "Plugin setup complete!"

Scenario 2: Emergency Plugin Update

Problem: Critical security update released for a plugin.

Solution:

# Backup first
wp db export emergency-backup-$(date +%Y%m%d-%H%M).sql

# Update the vulnerable plugin
wp plugin update vulnerable-plugin

# Verify update
wp plugin get vulnerable-plugin --field=version

# Test site functionality
curl -I https://yoursite.com

Scenario 3: Bulk Update Across Multiple Sites

#!/bin/bash
# update-all-sites.sh

sites=(
"/var/www/site1"
"/var/www/site2"
"/var/www/site3"
)

for site in "${sites[@]}"; do
echo "Updating plugins for $site"
wp plugin update --all --path=$site
echo "---"
done

Scenario 4: Downgrade Plugin After Bad Update

# Plugin update broke the site - downgrade to previous version
wp plugin install woocommerce --version=8.2.0 --force --activate

# Verify downgrade
wp plugin get woocommerce --field=version

Scenario 5: Install Premium Plugin Stack

#!/bin/bash
# install-premium-plugins.sh

# Install premium plugins from private storage
wp plugin install https://secure.example.com/plugins/gravityforms.zip --activate
wp plugin install https://secure.example.com/plugins/acf-pro.zip --activate
wp plugin install ./premium/elementor-pro.zip --activate

echo "Premium plugins installed!"

Best Practices

1. Always Backup Before Updates

# Create backup script
#!/bin/bash
# backup-before-update.sh

# Backup database
wp db export "backups/db-$(date +%Y%m%d-%H%M).sql"

# Backup plugins directory
tar -czf "backups/plugins-$(date +%Y%m%d-%H%M).tar.gz" wp-content/plugins/

# Now safe to update
wp plugin update --all

2. Use Dry Run for Safety

# Preview updates before applying
wp plugin update --all --dry-run

# Review output, then apply
wp plugin update --all

3. Test on Staging First

# On staging environment
wp plugin update --all
# Test thoroughly...

# On production (after successful staging test)
wp plugin update --all

4. Lock Plugin Versions in Development

# Install specific versions for consistency
wp plugin install woocommerce --version=8.2.0
wp plugin install elementor --version=3.16.0

# Document in project README or deployment script

5. Automate Regular Updates

# Add to crontab for weekly updates
0 2 * * 0 cd /var/www/html && wp plugin update --all --quiet

# With email notification
0 2 * * 0 cd /var/www/html && wp plugin update --all 2>&1 | mail -s "Plugin Updates" admin@example.com

6. Remove Unused Plugins

# List inactive plugins
wp plugin list --status=inactive

# Delete unused plugins (security best practice)
wp plugin delete akismet hello

Troubleshooting

Plugin Installation Fails

# Check for errors
wp plugin install plugin-name 2>&1 | tee install-error.log

# Common issues:
# 1. Permissions - check wp-content/plugins/ is writable
ls -la wp-content/

# 2. Disk space
df -h

# 3. PHP memory limit
wp eval 'echo WP_MEMORY_LIMIT;'

Update Fails or Breaks Site

# Immediately restore from backup
wp db import backup-latest.sql

# Or reinstall previous version
wp plugin install plugin-name --version=1.2.3 --force

# Check error logs
tail -f wp-content/debug.log

Plugin Not Found in Repository

# Verify plugin slug
# Search WordPress.org or use exact slug

# If premium/custom, use ZIP or URL method
wp plugin install /path/to/plugin.zip

Quick Reference

Essential Commands

# Install plugins
wp plugin install <slug> # From WordPress.org
wp plugin install <slug> --activate # Install and activate
wp plugin install <slug> --version=1.2.3 # Specific version
wp plugin install /path/to/plugin.zip # From ZIP
wp plugin install https://url/plugin.zip # From URL
wp plugin install plugin1 plugin2 plugin3 # Bulk install

# Update plugins
wp plugin update <slug> # Update one plugin
wp plugin update --all # Update all plugins
wp plugin update --all --dry-run # Preview updates
wp plugin update <slug> --version=1.2.3 # Update to specific version

# Check plugins
wp plugin list # List all plugins
wp plugin list --status=active # List active only
wp plugin list --update=available # List with updates
wp plugin get <slug> # Get plugin details
wp plugin path <slug> # Get plugin path

# Force operations
wp plugin install <slug> --force # Force reinstall

Common Workflows

# Safe update workflow
wp db export backup.sql
wp plugin update --all --dry-run
wp plugin update --all
# Test site...

# New site plugin setup
wp plugin install contact-form-7 wordfence updraftplus --activate

# Emergency plugin disable (covered in Activation & Status)
wp plugin deactivate --all

Comparison: WP-CLI vs wp-admin

TaskWP-CLIwp-admin
Install 10 Plugins~30 seconds10+ minutes
Update All Plugins~10 seconds5-10 minutes
Bulk Operations✅ Native⚠️ Limited
Version Control✅ Precise⚠️ Latest only
Automation✅ Fully scriptable❌ Manual
Works When Site Broken✅ Yes❌ No
Preview Before Install❌ No✅ Yes
Key Takeaway

WP-CLI excels at speed, automation, and bulk operations. Use it for deployments, updates, and troubleshooting. Use wp-admin when you need to browse and preview plugins before installation.

Next Steps