Table of Contents
If you want to speed up your development workflow, mastering WP-CLI commands is the ultimate game-changer. Logging into the WordPress admin dashboard, navigating through multiple menus, and clicking through options is fine for casual bloggers, but as a professional developer, your time is valuable. By executing tasks directly from your command-line interface, you can accomplish in seconds what used to take minutes, paving the way for seamless WordPress automation.
In this guide, we have compiled a comprehensive list of 30 essential WP-CLI commands that every WordPress developer should have in their toolkit. From automated installations to database optimization, plugin management, and server administration, these commands will transform your terminal into a powerful administration panel.
What is WP-CLI and Why Use It?
WP-CLI is the official command-line interface for WordPress. It allows you to manage almost every aspect of a WordPress site without opening a web browser. With WP-CLI, you can update plugins, configure multisite installations, perform database migrations, and bulk-generate content via command-line arguments. Additionally, because WP-CLI bypasses the web browser, it avoids timeout limits on heavy operations, making it incredibly fast and reliable.
To use these commands, you must have SSH access to your web server and have the WP-CLI tool installed. For detailed installation steps, check out our comprehensive WP-CLI Beginner’s Guide.
Essential WP-CLI Commands for Core Installation and Updates
Setting up a fresh WordPress environment can be tedious. Use these core commands to install, update, and manage the base WordPress application instantly.
1. wp core download
This command downloads the latest version of WordPress directly into your current directory. It automatically pulls files from the official WordPress repository.
wp core downloadYou can also download a specific version or language by appending flags:
wp core download --version=6.4.2 --locale=en_GB2. wp core config
Generate your wp-config.php file securely without manually copying and pasting database credentials.
wp core config --dbname=my_db_name --dbuser=db_user --dbpass=secure_password --dbhost=localhost3. wp core install
Run the famous WordPress five-minute installation in less than five seconds.
wp core install --url=https://yourdomain.com --title=\"My WP-CLI Site\" --admin_user=admin_username --admin_password=strong_password_here --admin_email=info@yourdomain.com4. wp core update
Keep your WordPress core up to date without visiting the dashboard. It checks for updates and installs them automatically.
wp core update5. wp core update-db
After a core update, the WordPress database schema may need updating. Execute this command to perform the database upgrade instantly.
wp core update-db6. wp core version
Quickly verify the exact version of WordPress currently running on your server.
wp core versionSpeed up Database Tasks with WP-CLI Commands
Managing databases is a critical aspect of development. These commands allow you to back up, restore, search, and optimize your database effortlessly.
7. wp db export
Generate a SQL backup file of your WordPress database in a split second. This is an essential step before running risky operations or during migrations.
wp db export my_backup_file.sql8. wp db import
Import a SQL backup file straight into your database with no maximum upload limit constraints.
wp db import my_backup_file.sql9. wp db search-replace
This is arguably one of the most powerful WP-CLI commands. It allows you to safely search and replace strings (like changing domains) throughout your database without breaking PHP serialized data.
wp db search-replace 'https://staging.example.com' 'https://example.com' --dry-runTip: Always use the --dry-run flag first to preview your changes before altering the database.
10. wp db query
Execute custom SQL queries directly from your terminal. This saves you from having to log in to phpMyAdmin or connect via an external client.
wp db query \"SELECT count(*) FROM wp_posts;\"11. wp db optimize
Optimize your database tables to clean up overhead and improve site performance.
wp db optimize12. wp db reset
Need to start from scratch? This command drops all tables in the database. Be extremely careful when using this!
wp db reset --yesPlugin and Theme Management Using WP-CLI Commands
With these automated WP-CLI commands, you no longer need to manually log in to search, upload, and activate plugins or themes.
13. wp plugin list
View a formatted table of all installed plugins, along with their status (active/inactive), version, and whether updates are available.
wp plugin list14. wp plugin install
Install any plugin from the WordPress.org directory. You can also install multiple plugins simultaneously.
wp plugin install contact-form-7 woocommerce --activateTo install a plugin from a local zip file or a remote URL, pass the path directly:
wp plugin install https://downloads.wordpress.org/plugin/akismet.zip --activate15. wp plugin activate
Activate an installed plugin instantly. This is extremely useful if a plugin conflict locks you out of your WP-Admin.
wp plugin activate wp-super-cache16. wp plugin deactivate
Deactivate one or more plugins without touching the dashboard. Perfect for troubleshooting security issues.
wp plugin deactivate --all17. wp plugin update
Update all your plugins, or target a specific one, to keep your site secure.
wp plugin update --all18. wp theme list
Display all installed themes, noting which one is currently active.
wp theme list19. wp theme install
Download and install a theme. You can active it immediately with the --activate flag.
wp theme install twentytwentyfour --activate20. wp theme update
Update your themes via CLI in seconds.
wp theme update --allUser Administration Commands
If you lose your WordPress password or need to generate test accounts, these commands are incredibly helpful.
21. wp user create
Create a new user account instantly. You can assign any role, including Administrator.
wp user create developer_jane jane@example.com --role=administrator --user_pass=jane_secure_password22. wp user list
Get a clean overview of all registered users on your website, organized by role.
wp user list23. wp user update
Update user details, such as changing a password or editing meta fields.
wp user update developer_jane --user_pass=new_ultra_secure_pass24. wp user delete
Delete a user. You can reassign their authored posts to another user ID using the --reassign flag.
wp user delete developer_jane --reassign=1Content and Media Automation
Scale your development by automating content generation, importing bulk media assets, and rebuilding assets.
25. wp post create
Quickly draft or publish articles without leaving your code editor.
wp post create --post_type=page --post_title=\"Privacy Policy\" --post_status=publish26. wp post generate
Need dummy data for testing theme layouts or performance benchmarking? Generate hundreds of placeholder posts instantly.
wp post generate --count=5027. wp media import
Import local files into the WordPress Media Library and attach them to posts automatically.
wp media import /path/to/local/image.webp --post_id=4528. wp media regenerate
If you change your theme’s image sizes, use this command to regenerate all thumbnails without having to install bulky plugins.
wp media regenerate --yesMaintenance, Performance, and Cache Management
Fine-tune your server’s performance, clear out junk files, and refresh system caches using these advanced commands.
29. wp transient delete
Transients are used to temporarily store cached data in your database. Clearing expired or broken transients can resolve unexpected UI glitches.
wp transient delete --expiredTo delete all transients completely:
wp transient delete --all30. wp cache flush
Flush your object cache completely. This is incredibly helpful when working with Redis or Memcached servers where updates aren’t showing up instantly.
wp cache flushWP-CLI vs WP-Admin: Efficiency Comparison
Below is a direct comparison highlighting why developers rely on WP-CLI commands over the graphical user interface for everyday tasks.
| Action | WP-Admin GUI Process | WP-CLI CLI Process | Time Saved |
|---|---|---|---|
| Install & Activate Plugin | Navigate to Plugins -> Add New -> Search -> Install -> Activate | wp plugin install name --activate | ~80% faster |
| Database Backup (Export) | Install backup plugin -> Configure settings -> Click Export -> Download file | wp db export | ~95% faster |
| Update Core, Plugins, Themes | Navigate to Updates -> Check boxes -> Click Update on multiple screens | wp core update && wp plugin update --all && wp theme update --all | ~90% faster |
| Reset User Password | Go to Users -> Profile -> Generate Password -> Copy/Paste -> Save Profile | wp user update username --user_pass="pass" | ~75% faster |
Best Practices for WordPress Automation with WP-CLI
To implement WordPress automation safely and professionally, you should always follow developer best practices:
- Always backup first: Before running updates or search-replace scripts, use
wp db export. - Write shell scripts: Combine your favorite WP-CLI commands into a bash file (e.g.,
deploy.sh) to provision new staging sites instantly. - Use aliases: Configure WP-CLI aliases so you can control remote production sites securely from your local terminal using SSH tunnels.
- Integrate with CI/CD: Add CLI commands into your GitHub Actions or GitLab pipelines to run automatic database updates upon code deployment.
Conclusion
Mastering WP-CLI is one of the most rewarding milestones for a WordPress developer. By integrating these 30 useful commands into your workflow, you unlock unparalleled speed, efficiency, and the unlimited potential of WordPress automation. Stop clicking, start typing, and take total control over your development environment today!
“The CLI is not about doing things differently; it is about doing things faster, consistently, and without limitations.” – WP Educated Development Team
For more technical tips and tutorials on speed optimization and server management, explore our deep dive into [Internal Link: WordPress Hosting Optimization Guide].
Related Blogs
- November 28, 2026
- 7 min read
- November 27, 2026
- 7 min read
- November 26, 2026
- 8 min read