Here’s our complete, professional WP-CLI Cheat Sheet covering all the commands you need for WordPress development, maintenance, debugging, and automation. Anyone can use it as a reference or guide for daily tasks.
WP-CLI Cheat Sheet
1. General WordPress Commands
| Task |
Command |
| Check WP version |
wp core version |
| Update WP core |
wp core update |
| Update WP core to a specific version |
wp core update --version=6.4.1 |
| Update WP database after core update |
wp core update-db |
| Check WP installation status |
wp core status |
| Download a specific WordPress version |
wp core download --version=6.4.1 |
| Generate wp-config.php |
wp config create --dbname=DB_NAME --dbuser=DB_USER --dbpass=DB_PASSWORD --dbhost=localhost --dbprefix=wp_ |
2. Plugin Management
| Task |
Command |
| List installed plugins |
wp plugin list |
| Install plugin |
wp plugin install plugin-slug |
| Install & activate plugin |
wp plugin install plugin-slug --activate |
| Activate plugin |
wp plugin activate plugin-slug |
| Deactivate plugin |
wp plugin deactivate plugin-slug |
| Update a plugin |
wp plugin update plugin-slug |
| Update all plugins |
wp plugin update --all |
| Delete plugin |
wp plugin delete plugin-slug |
3. Theme Management
| Task |
Command |
| List installed themes |
wp theme list |
| Install theme |
wp theme install theme-slug |
| Install & activate theme |
wp theme install theme-slug --activate |
| Activate theme |
wp theme activate theme-slug |
| Update theme |
wp theme update theme-slug |
| Update all themes |
wp theme update --all |
| Delete theme |
wp theme delete theme-slug |
4. User Management
| Task |
Command |
| List users |
wp user list |
| Create user |
wp user create username email@example.com --role=role --user_pass=Password123 |
| Update user role |
wp user update username --role=administrator |
| Update user password |
wp user update username --user_pass=NewPass123 |
| Delete user |
wp user delete username --reassign=admin |
5. Posts & Pages Management
| Task |
Command |
| List posts |
wp post list --post_type=post |
| Create a post |
wp post create --post_type=post --post_title="My Post" --post_status=publish |
| Update post |
wp post update 123 --post_title="Updated Title" |
| Delete post |
wp post delete 123 --force |
| List pages |
wp post list --post_type=page |
| Create a page |
wp post create --post_type=page --post_title="About" --post_status=publish |
6. Database Management
| Task |
Command |
| Export DB |
wp db export filename.sql |
| Import DB |
wp db import filename.sql |
| Optimize DB |
wp db optimize |
| Check DB |
wp db check |
| Repair DB |
wp db repair |
| Search & Replace |
wp search-replace 'http://oldsite.com' 'https://newsite.com' --all-tables |
| Create DB |
wp db create |
| Drop DB |
wp db drop --yes |
7. Maintenance & Debugging
| Task |
Command |
| Enable WP debug |
wp config set WP_DEBUG true --raw |
| Enable debug log |
wp config set WP_DEBUG_LOG true --raw |
| Disable debug display |
wp config set WP_DEBUG_DISPLAY false --raw |
| Enable maintenance mode |
wp maintenance-mode activate |
| Disable maintenance mode |
wp maintenance-mode deactivate |
| Flush cache |
wp cache flush |
| Generate salts |
wp config shuffle-salts |
8. Cron Jobs
| Task |
Command |
| List scheduled events |
wp cron event list |
| Run scheduled events |
wp cron event run --due-now |
| Delete scheduled event |
wp cron event delete event-hook |
9. Multisite Management
| Task |
Command |
| List sites |
wp site list |
| Create a new site |
wp site create --slug=newsite --title="New Site" --email=admin@example.com |
| Delete a site |
wp site delete 2 --yes |
| Update site URL |
wp site update 2 --domain=newdomain.com |
10. Search & Replace / Migration
| Task |
Command |
| Replace URLs in DB |
wp search-replace 'http://old.com' 'https://new.com' |
| Dry run before replace |
wp search-replace 'old' 'new' --dry-run |
| Replace in specific table |
wp search-replace 'old' 'new' wp_posts |
11. Miscellaneous
| Task |
Command |
| Check WordPress environment |
wp doctor check |
| List active theme |
wp theme list --status=active |
| List active plugins |
wp plugin list --status=active |
| Export all options |
wp option list |
| Update all options |
wp option update option_name "value" |
| Import/export media |
wp media import /path/to/image.jpg |
12. Aliases & Environment Shortcuts
- Define environments in
wp-cli.yml:
@local:
path: /var/www/html
@staging:
url: https://staging.example.com
@production:
url: https://example.com
- Run commands for specific site:
wp @staging plugin update --all
wp @production db export backup.sql
✅ Pro Tips
- Always backup your database before destructive operations.
- Use
--dry-run for commands like search-replace and deletion.
- Combine WP-CLI with cron for automated updates/backups.
- Use WP-CLI with scripts for repetitive multi-site management.
- Use
wp help for detailed documentation on any command.
Need Expert WordPress Automation?
Managing high-traffic WordPress sites requires more than just a cheat sheet. At NeedleCode, we specialize in:
- Custom WP-CLI Scripting: Automate backups, updates, and migrations.
- Enterprise Hosting Setup: Optimized server environments for maximum speed.
- Advanced Database Optimization: Hardening and scaling large-scale databases.
Ready to scale your WordPress site? Contact NeedleCode Today for professional WordPress development and optimization services.