Introduction & Installation

What is WP-CLI and why to use it?

WordPress Command Line Interface ( WP-CLI) is a command line tool for WordPress which 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 – user can create their own commands to perform and custom function

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 wordpress site version here –

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

  • Installing and updating WordPress site, themes, 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 Installing handbook page to know more.

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