Install and Manage WordPress Plugins with WP-CLI #
WP-CLI, the WordPress Command Line Interface, is a game-changer for managing WordPress plugins efficiently. Whether you’re a developer, site administrator, or handling multiple WordPress sites, WP-CLI lets you install, update, activate, deactivate, and manage plugins directly from the command line, saving time and reducing errors. In this SEO-optimized guide from Temply Studio, we’ll walk you through using WP-CLI for plugin management with step-by-step instructions and practical examples.
What is WP-CLI? #
WP-CLI is an open-source command-line tool designed to streamline WordPress administration tasks. From installing plugins to managing themes and users, WP-CLI eliminates the need to navigate the WordPress dashboard, making it ideal for developers and power users.
Why Use WP-CLI for Plugin Management?
– Speed: Execute tasks faster than using the dashboard.
– Automation: Script repetitive tasks for efficiency.
– Bulk Operations: Manage plugins across multiple sites with one command.
– Precision: Avoid manual errors with precise commands.
Prerequisite: WP-CLI requires a server with PHP 7.4 or higher and WordPress installed. You’ll also need SSH access. Visit the official WP-CLI installation guide for setup details.
Step 1: Install WP-CLI #
Before managing plugins, ensure WP-CLI is set up on your server. Follow these steps:
1. Download WP-CLI: Run this command to download the WP-CLI PHAR file:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
2. Make it Executable: Set permissions:
chmod +x wp-cli.phar
3. Move to System Path: Move the file for global access:
sudo mv wp-cli.phar /usr/local/bin/wp
4. Verify Installation: Confirm WP-CLI is working:
wp --info
You should see details about your WP-CLI version and environment.
Step 2: Install a Plugin with WP-CLI #
WP-CLI simplifies plugin installation, whether from WordPress.org or a ZIP file (e.g., from a GPL marketplace like GPLVault).
Install from WordPress.org:
To install a plugin like Yoast SEO, navigate to your WordPress root directory (where wp-config.php resides) and run:
wp plugin install yoast-seo --activate
The --activate flag activates the plugin immediately.
Install from a ZIP File:
For premium or GPL plugins, download the ZIP file to your server (e.g., via wget or FTP), then run:
wp plugin install /path/to/plugin.zip --activate
Replace /path/to/plugin.zip with the file’s path. Omit --activate if you prefer to activate later.
Security Tip: Download ZIP files only from trusted sources to avoid malware. Always verify the plugin’s version and changelog.
Step 3: Update Plugins with WP-CLI #
Regular plugin updates are essential for security and compatibility. WP-CLI makes this process seamless.
Check for Updates:
List plugins with available updates:
wp plugin update --all --dry-run
The --dry-run flag previews updates without applying them.
Update a Single Plugin:
Update a specific plugin (e.g., Yoast SEO):
wp plugin update yoast-seo
Update All Plugins:
Update all outdated plugins:
wp plugin update --all
Update from a ZIP File:
For GPL or premium plugins, download the updated ZIP and run:
wp plugin install /path/to/updated-plugin.zip --force
The --force flag overwrites the existing plugin.
Step 4: Activate or Deactivate Plugins #
Toggle plugin status with ease using WP-CLI.
Activate a Plugin:
Activate a plugin like WooCommerce:
wp plugin activate woocommerce
Deactivate a Plugin:
Deactivate a plugin:
wp plugin deactivate woocommerce
Bulk Operations:
Activate multiple plugins:
wp plugin activate plugin-slug-1 plugin-slug-2
Deactivate all plugins (great for troubleshooting):
wp plugin deactivate --all
Step 5: Advanced Plugin Management #
WP-CLI offers powerful commands for deeper plugin management:
List Installed Plugins:
View all plugins with their status and version:
wp plugin list
Delete a Plugin:
Remove an unused plugin (deactivate first):
wp plugin delete plugin-slug
Search for Plugins:
Search WordPress.org for plugins:
wp plugin search "keyword"
Check Plugin Status:
Verify a plugin’s status:
wp plugin status plugin-slug
Pro Tip: Automate plugin management by integrating WP-CLI commands into shell scripts. For example, create a script to update plugins across multiple sites with wp plugin update --all.
Troubleshooting WP-CLI Plugin Issues #
Encounter issues? Here are solutions to common problems:
“Command Not Found”: Ensure WP-CLI is in your system’s PATH. Run wp --info to verify installation.
Permission Errors: Fix permissions for wp-content/plugins (755 for folders, 644 for files):
chmod -R 755 wp-content/plugins
Installation Fails: Verify the plugin slug or ZIP path. Re-download ZIP files if corrupted.
Site Breaks After Update: Deactivate the plugin with wp plugin deactivate plugin-slug and restore from a backup. Check compatibility with your WordPress version.
Memory Limit Issues: Increase PHP memory by adding define('WP_MEMORY_LIMIT', '256M'); to wp-config.php.
Backup First: Always back up your site’s database and files before running WP-CLI commands. Use plugins like UpdraftPlus or your host’s backup tools.
Why WP-CLI for Plugin Management? #
WP-CLI empowers WordPress users to manage plugins with speed and precision, making it ideal for developers, agencies, and site owners managing multiple sites. By mastering WP-CLI, you can streamline workflows, enhance site performance, and focus on creating stunning websites with Temply Studio’s design resources.
Want to dive deeper? Check out our Resources for more WordPress tutorials, or reach out to Temply Studio Support for expert help.
Add comment