20 Essential WP-CLI Commands Every WordPress Developer Should Know

Clicking through WordPress admin panels to update plugins, check site status, or manage users wastes hours every week. You know there’s a faster way, but memorizing hundreds of WP-CLI commands feels overwhelming.

WP-CLI has over 1,000 commands, but you only need about 20 to handle 90% of daily WordPress development tasks. Master these essential commands, and you’ll dramatically increase your productivity and efficiency.

In this guide, you’ll learn the 20 most powerful WP-CLI commands that professional WordPress developers use daily—complete with practical examples and real-world use cases.

Why Master Essential WP-CLI Commands?

WP-CLI documentation lists hundreds of commands, but most developers use the same core set repeatedly.

Problems with GUI WordPress Management

Repetitive clicking: Installing 10 plugins means 10 separate install-and-activate workflows.

No batch operations: Can’t update all themes or export all user data at once.

Time waste: Simple tasks like flushing cache require multiple page loads.

No automation: Can’t script routine maintenance or deployment tasks.

Context switching: Moving between terminal and browser breaks workflow.

Essential Commands Advantages

Speed: Execute complex operations in seconds instead of minutes.

Muscle memory: Same 20 commands handle most scenarios across all sites.

Scriptable: Chain commands together for powerful automation workflows.

SSH-ready: Manage remote servers without leaving your terminal.

Reliable: Commands work identically across all WordPress installations.

According to WordPress developer surveys, developers who use WP-CLI save an average of 5-10 hours per week on routine tasks.

Core WordPress Commands

Manage WordPress core installation and configuration.

1. Check WordPress Version

# Show current WordPress version
wp core version

# Show detailed version info
wp core version --extra

# Check if core update available
wp core check-update

Use Case: Quickly verify WordPress version before applying updates or troubleshooting compatibility issues.

2. Update WordPress Core

# Update to latest version
wp core update

# Update to specific version
wp core update --version=6.4.2

# Preview update without installing
wp core update --dry-run

Pro Tip: Always backup database before core updates with wp db export backup.sql.gz.

3. Verify WordPress Installation

# Check if WordPress is installed
wp core is-installed

# Check and return exit code (useful in scripts)
wp core is-installed && echo "WordPress is installed"

# Verify file integrity
wp core verify-checksums

Use Case: Verify WordPress files haven’t been corrupted or tampered with during security audits.

Learn more in the official WP-CLI core commands documentation.

Plugin Management Commands

Control plugins efficiently from command line.

4. List Installed Plugins

# List all plugins
wp plugin list

# Show only active plugins
wp plugin list --status=active

# Export to CSV for inventory
wp plugin list --format=csv > plugins-inventory.csv

5. Install and Activate Plugins

# Install plugin
wp plugin install wordfence

# Install and activate immediately
wp plugin install contact-form-7 --activate

# Install multiple plugins at once
wp plugin install wordfence yoast-seo autoptimize --activate

Use Case: Set up standard plugin stack on new WordPress installations in seconds.

6. Update Plugins

# Update all plugins
wp plugin update --all

# Update specific plugin
wp plugin update wordfence

# Preview updates without installing
wp plugin update --all --dry-run

Pro Tip: Use --dry-run on production to preview which plugins need updates before applying them.

Theme Management Commands

Manage WordPress themes quickly.

7. List and Activate Themes

# List all themes
wp theme list

# Activate theme
wp theme activate twentytwentyfour

# Install and activate theme
wp theme install astra --activate

8. Update Themes

# Update all themes
wp theme update --all

# Update specific theme
wp theme update astra

Use Case: Keep all themes updated for security without clicking through admin panel.

Database Management Commands

Handle database operations safely and efficiently.

9. Export Database

# Basic database export
wp db export

# Export with custom filename
wp db export backup-$(date +%Y%m%d).sql

# Export with compression (recommended)
wp db export backup.sql.gz

Critical: Export before any major changes—updates, migrations, or content modifications.

10. Import Database

# Import database
wp db import backup.sql

# Import compressed database
wp db import backup.sql.gz

11. Search and Replace URLs

# Replace URLs in database
wp search-replace 'http://oldsite.com' 'https://newsite.com'

# Preview changes without applying (always use first!)
wp search-replace 'old.com' 'new.com' --dry-run

# Replace with report showing all changes
wp search-replace 'old' 'new' --report --dry-run

Use Case: Essential for site migrations, domain changes, and HTTP to HTTPS upgrades. Learn more about WordPress database management.

12. Optimize Database

# Optimize all tables
wp db optimize

# Check database for errors
wp db check

# Repair corrupted tables
wp db repair

User Management Commands

Create and manage WordPress users from terminal.

13. List Users

# List all users
wp user list

# Show only administrators
wp user list --role=administrator

# Export users to CSV
wp user list --format=csv > users.csv

14. Create Users

# Create user (prompts for password)
wp user create johndoe john@example.com

# Create with specific role
wp user create editor1 editor@example.com --role=editor

# Create and send password via email
wp user create newuser user@example.com --send-email

Use Case: Quickly onboard new team members or clients without using WordPress admin.

15. Reset User Password

# Reset password (sends email)
wp user reset-password admin

# Set specific password
wp user update admin --user_pass=NewSecureP@ssw0rd123

Content Management Commands

Manage posts, pages, and content efficiently.

16. List Posts

# List all posts
wp post list

# Show only published posts
wp post list --post_status=publish

# Filter by category
wp post list --category_name=tutorials

# Count total posts
wp post list --format=count

17. Create and Update Posts

# Create post
wp post create --post_title="New Post" --post_status=publish

# Create with content
wp post create --post_title="Hello" --post_content="Post content here" --post_status=publish

# Update post
wp post update 123 --post_title="Updated Title"

Use Case: Bulk create test content for development environments or automate content publishing.

Cache and Maintenance Commands

Keep WordPress running smoothly with maintenance commands.

# Flush object cache
wp cache flush

# Flush rewrite rules (permalinks)
wp rewrite flush

# Combined flush for troubleshooting
wp cache flush && wp rewrite flush

Use Case: First step in troubleshooting 404 errors or stale content issues.

19. Clean Transients

# Delete expired transients
wp transient delete --expired

# Delete all transients (safe, they regenerate)
wp transient delete --all

# List all transients
wp transient list

Pro Tip: Deleting expired transients can reduce database size by 10-30% on older sites.

Configuration and Options Commands

Manage WordPress configuration and options.

20. Manage Options

# Get option value
wp option get siteurl

# Update option
wp option update blogdescription "My awesome site"

# List all options (warning: very long output)
wp option list

# Add new option
wp option add custom_setting "custom value"

Use Case: Quickly change site URL, title, or custom plugin settings without database queries.

Command Combinations for Power Users

Chain essential commands for powerful workflows.

Quick Site Setup

# Install WordPress, plugins, and configure
wp core download
wp config create --dbname=wordpress --dbuser=root --dbpass=password
wp core install --url=example.com --title="My Site" --admin_user=admin --admin_email=admin@example.com
wp plugin install wordfence contact-form-7 yoast-seo --activate
wp theme install astra --activate

Complete Site Backup

# Backup database and files
DATE=$(date +%Y%m%d)
wp db export backup-$DATE.sql.gz
tar -czf files-backup-$DATE.tar.gz wp-content/
echo "Backup complete: backup-$DATE.sql.gz + files-backup-$DATE.tar.gz"

Site Health Check

# Check core, verify files, update everything
wp core version
wp core verify-checksums
wp plugin update --all --dry-run
wp theme update --all --dry-run
wp db check

Next Steps

You now have the 20 essential WP-CLI commands that cover 90% of daily WordPress development tasks.

Week 1: Practice core commands

  • Install/update WordPress core
  • Manage plugins and themes
  • Basic database exports

Week 2: User and content management

  • Create and manage users
  • Bulk content operations
  • Search-replace operations

Week 3: Automation basics

  • Chain commands together
  • Create simple backup scripts
  • Automate routine maintenance

Week 4: Advanced workflows

  • Build deployment scripts
  • Implement automated testing
  • Create custom commands

Advanced Topics

  1. WP-CLI Configuration Files – Customize WP-CLI behavior
  2. WP-CLI Packages – Extend functionality with community packages
  3. Custom WP-CLI Commands – Build your own commands

Get More Resources

Download WP-CLI command cheatsheet – Quick reference for all 20 commands

Join our email course for:

  • Weekly WP-CLI tutorials
  • Advanced automation techniques
  • Real-world case studies

Conclusion

These 20 essential WP-CLI commands form the foundation of efficient WordPress development. You don’t need to memorize hundreds of commands—just master these core operations.

What we covered:

✅ Core WordPress management (version, update, verify)
✅ Plugin and theme operations (install, update, activate)
✅ Database commands (export, import, search-replace, optimize)
✅ User management (create, list, password reset)
✅ Content operations (list, create, update posts)
✅ Maintenance commands (cache flush, transients, options)

Start using these commands daily, and within two weeks they’ll become second nature. Your productivity will skyrocket, and you’ll wonder how you ever managed WordPress without them.

Ready to level up? Learn WP-CLI automation with bash scripts or advanced database operations.

Questions about essential WP-CLI commands? Drop a comment below!

Found this helpful? Share with other WordPress developers.