WP-CLI
WP-CLI (WordPress Command Line Interface) is a powerful tool that allows you to manage your WordPress site using the command line or terminal, instead of the admin dashboard. It’s especially useful for developers, sysadmins, and anyone managing multiple or large-scale WordPress sites.
What Can You Do with WP-CLI?
With WP-CLI, you can perform almost any administrative or development task – faster and more efficiently – without logging into the WordPress dashboard.
Task | Command Example |
---|---|
Check WordPress version | wp core version |
Install a plugin | wp plugin install akismet |
Update all plugins | wp plugin update --all |
Create a new post | wp post create --post_title="Hello World" |
Export database | wp db export |
Search and replace in the DB | wp search-replace 'oldurl.com' 'newurl.com' |
Clear cache (for supported plugins) | wp cache flush |
Installing WP-CLI
- Make sure your server supports PHP 5.6+ and UNIX-like OS (Linux, macOS).
- Download the Phar file: bashCopyEdit
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- Make it executable: bashCopyEdit
chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp
- Test: bashCopyEdit
wp --info
Advantages of WP-CLI
- Faster workflows — especially for batch operations
- Automation-ready — ideal for scripts, CI/CD, deployment pipelines
- Remote management — when combined with SSH or WP REST API
- Plugin and theme scaffolding — easily create boilerplates