HomeWORDPRESSHow do you use WP_CLI and what are its advantages?

How do you use WP_CLI and what are its advantages?

What is WP-CLI?

  • WP-CLI is the command-line interface for WordPress.
  • Lets you manage WordPress sites using terminal commands instead of the admin dashboard.

How to Use WP-CLI

1. Install WP-CLI

  • Download and install globally:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

2. Common WP-CLI Commands

TaskCommand
Check WordPress versionwp core version
Install WordPresswp core download
Update WordPresswp core update
Manage pluginswp plugin install plugin-name --activate
Manage themeswp theme install theme-name --activate
Create admin userwp user create admin admin@example.com --role=administrator --user_pass=pass123
Search & replace in DBwp search-replace 'old.com' 'new.com'
Export DBwp db export
Import DBwp db import file.sql

3. Example Workflow

Install and activate a plugin:

wp plugin install woocommerce --activate

Update all plugins:

wp plugin update --all

Clear transients:

wp transient delete --all

Advantages of WP-CLI

  1. Speed – Perform tasks faster than using the dashboard.
  2. Automation – Useful for scripts, CI/CD pipelines, and bulk tasks.
  3. Remote Management – Manage multiple sites via SSH.
  4. No Browser Needed – Works even when WP Admin is inaccessible.
  5. Low Server Load – Bypasses admin UI overhead.

💡 Analogy:
Using WP-CLI is like using a power drill instead of a screwdriver — both can do the job, but one is faster, more powerful, and better for bulk work.

Share: 

No comments yet! You be the first to comment.

Leave a Reply

Your email address will not be published. Required fields are marked *