What is WP-CLI?
- WP-CLI is the command-line interface for WordPress.
- Lets you manage WordPress sites using terminal commands instead of the admin dashboard.
How to Use WP-CLI
1. Install WP-CLI
- Download and install globally:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp2. Common WP-CLI Commands
| Task | Command |
|---|---|
| Check WordPress version | wp core version |
| Install WordPress | wp core download |
| Update WordPress | wp core update |
| Manage plugins | wp plugin install plugin-name --activate |
| Manage themes | wp theme install theme-name --activate |
| Create admin user | wp user create admin admin@example.com --role=administrator --user_pass=pass123 |
| Search & replace in DB | wp search-replace 'old.com' 'new.com' |
| Export DB | wp db export |
| Import DB | wp db import file.sql |
3. Example Workflow
Install and activate a plugin:
wp plugin install woocommerce --activateUpdate all plugins:
wp plugin update --allClear transients:
wp transient delete --allAdvantages of WP-CLI
- Speed – Perform tasks faster than using the dashboard.
- Automation – Useful for scripts, CI/CD pipelines, and bulk tasks.
- Remote Management – Manage multiple sites via SSH.
- No Browser Needed – Works even when WP Admin is inaccessible.
- Low Server Load – Bypasses admin UI overhead.
💡 Analogy:
Using WP-CLI is like using a power drill instead of a screwdriver — both can do the job, but one is faster, more powerful, and better for bulk work.
