WP-CLI: A Comprehensive Guide to Managing WordPress from the Command Line
Published on September 19, 2025
WP-CLI: A Comprehensive Guide to Managing WordPress from the Command Line
Introduction
WP-CLI is the official command-line tool for WordPress, allowing you to manage your sites without logging into the admin panel. With WP-CLI, you can install plugins, update WordPress core, manage users, handle database tasks, and even run advanced automation workflows.
In this guide, we’ll explore what WP-CLI is, how to install it, and provide practical examples of its most useful commands.
What is WP-CLI?
WP-CLI (WordPress Command Line Interface) is a PHP-based tool that enables direct interaction with WordPress through the terminal. It covers almost all admin tasks and sometimes goes beyond the WordPress dashboard:
- Installing and updating WordPress core, plugins, and themes
- Managing users, posts, and the database
- Running bulk operations across multiple sites
- Remote management via SSH
- Automating workflows with scripts
Benefits of WP-CLI
- Efficiency: Tasks are completed much faster compared to the admin panel.
- Bulk operations: Update all plugins or clear caches across multiple sites with one command.
- Automation: Use WP-CLI inside Bash or PHP scripts for deployments, backups, or migrations.
- Remote access: Manage WordPress via SSH without a browser.
- Extended functionality: Commands not available in the dashboard (e.g., clearing transients).
Installing WP-CLI
Requirements
- UNIX-like environment (Linux, macOS, FreeBSD).
- PHP 5.6+
- WordPress 3.7+
Installation steps
Download the Phar file:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Make it executable:
chmod +x wp-cli.phar
Move it to your
$PATH
:sudo mv wp-cli.phar /usr/local/bin/wp
Verify:
wp --info
For cPanel (no root access):
alias wp='~/wp-cli.phar'
echo "alias wp='~/wp-cli.phar'" >> ~/.bashrc
👉 WP-CLI can also be installed via Composer, Homebrew, or Docker.
Common WP-CLI Commands
Core management
wp core download --path=wp-site
wp core install --url="http://example.com" --title="My Site" --admin_user="admin" --admin_password="securepassword" --admin_email="admin@example.com"
wp core update
wp core install --skip-content
Plugins
wp plugin install akismet --activate
wp plugin update --all
wp plugin deactivate --all
Themes
wp theme install twentytwentyone --activate
wp theme list
Database
wp db export backup.sql
wp db import backup.sql
wp search-replace 'http://old.com' 'https://new.com' --dry-run
Users
wp user create newuser user@example.com --role=editor --user_pass=securepassword
wp user delete 42 --reassign=1
Content
wp post create --post_type=post --post_title="New Post" --post_status=publish
wp post generate --count=10
Advanced
wp transient delete --all
wp config set WP_DEBUG true --raw
wp eval 'echo get_option("siteurl");'
Advanced Features
Custom commands
Developers can write their own WP-CLI commands. Use:
wp scaffold package
to generate a template for custom commands.
Remote management
wp --ssh=user@host:/path/to/wordpress plugin install akismet --activate
Automation with scripts
#!/bin/bash
for site in /var/www/site1 /var/www/site2; do
wp --path=$site plugin update --all
done
Troubleshooting
- WP-CLI version:
wp cli version
- Command help:
wp help plugin install
- Debugging:
wp plugin install akismet --debug
Common issues:
- Permission denied → run as correct user.
- Path not found → specify
--path=/var/www/site
.
Conclusion
WP-CLI is a must-have for WordPress developers and administrators. It makes repetitive tasks faster, supports automation, and allows for remote management. By mastering its core commands, you’ll save time and gain better control over your WordPress projects.
📚 Learn more: wp-cli.org
Run wp help
to discover available commands.
Related Posts
Jitsi Meet vs Google Meet: when full control over data matters most
September 7, 2025
073 | Introduction to Virtualization: Why It’s Needed and How It Saves Time
August 4, 2025
065 | Why Network Resilience Is Not a Luxury, but a Necessity
July 27, 2025
064 | n8n + Xano: A Powerful No-Code Backend for Scalable Applications
July 26, 2025