Introduction & Installation

What is WP-CLI, and why use it?

WordPress Command Line Interface (WP-CLI) is a command line tool for WordPress that can directly interact with the site and manage all aspects of your WordPress site. With this method, you can complete a task by simply typing in a line of code and hitting Enter.

There are possibly two types of WP-CLI commands

  • Built-in commands – they are provided by core WP-CLI
  • Custom commands – users can create their own commands to perform custom functions.

Once you connect to your site via SSH or open your local terminal, you can enter simple commands to perform a task, which looks like this:

We are updating the WordPress site version here:

Here are various tasks that you can perform from command line:

  • Installing and updating WordPress sites, themes, and plugins.
  • Activating/deactivating WordPress themes, and plugins
  • Managing user creation and their roles, capabilities, and meta.
  • Performs basic database operations
  • Importing and exporting content
  • Managing posts, content, and meta.
  • Managing widgets, including adding and moving them within sidebars.
  • And so on…

For more information about WP-CLI, you can refer to the WP-CLI Handbook

Installing WP-CLI

There are multiple ways to install WP-CLI. Refer to the Installing handbook page to know more.

Check out this video for basic WP-CLI installation and configuring a website using it.

Ideas to Explore:

  • Different methods to log output in WP CLI.
  • How to add a command as a subcommand to an already existing command in WP CLI?
  • Command to downgrade the version to 6.3 of the WordPress installation.