DEV Community

Cover image for WP-CLI Example Guide
Abu Hurayra
Abu Hurayra

Posted on

WP-CLI Example Guide

What is wp-cli?

  • WP-CLI is the command line interface for WordPress.
  • It is an extensible tool for installing and maintaining WordPress.
  • Everything you can do from a browser, can also be done using the wp-cli.

In this guide we will learn some useful commands and create scripts to automate some common tasks.


Here are some of the most useful commands:

  • wp plugin update --all Update all plugins that can be updated.
  • wp db export Export the database an an SQL dump.
  • wp checksum core Verifies the integrity of the WordPress core and makes sure that the core files have not been tampered with.
  • wp plugin install user-switching --activate Install and activate a wordpress plugin.
  • wp transient delete --all Delete transient data.

Let's automate some common tasks using wp-cli:


User Create/Update/Delete/Generate:

  1. Create an editor named bob with the email bob@example.com and password b0bp@s52@0#2$3

wp user create bob bob@example.com --role=editor --user_pass=b0bp@s52@0#2$3

  1. Generate 100 subscribers

wp user generate --count=100 --role=subscriber

Top comments (0)