Built-in Commands

Since there are a lot of functions that we can perform by WP-CLI, there are separate commands to execute each action but most of them are straightforward.

For example:

  • wp admin command opens your admin area in the web browser.
  • wp config command generates and reads the wp-config.php file.

Some commands have subcommands which allow you to fine-tune your query.

For example: The ‘wp post’ command allows you to list, create, and delete a post. But to perform each of these actions, you need to use different sub-commands.

  • wp post create to create a new post.
  • wp post delete to delete one or more posts.
  • wp post list to get a list of posts.

All the commands accept some global parameters which provide some configurational arguments to the commands when executed.

For example:

  • wp post list –user=[email protected], here using –user global parameter we specified to list all posts of the user with this email.

You can find reference of all global parameters here.

Apart from global parameters, each command has its own set of parameters which could be used to configure the commands arguments.

For example:

  • wp db export --tables=wp_options,wp_users , here using –tables parameter we specified to export only wp_options and wp_users table from the database.

You can find the reference for all command-specific parameters from each command like for db export. If you want to know about any command from the CLI terminal itself, there is a command for that too.

  • wp help commandName

For example, wp help user  will show all details, subcommands, arguments supported by the user command here.

Here is a list of all the built-in WP-CLI Commands. Make sure you go through all of them!

More Examples

Using WP-CLI’s ‘wp db’ command, you can even export or import your database right from the terminal. Have a look at the below subcommands to read more about them.

  • wp db export – Exports the database to a file or to STDOUT.
  • wp db import – Imports a database from a file or from STDIN.

Watch the following videos to get an insight of built-in commands and global parameters:

Ideas to Explore:

Go through the subcommands and their options of the following commands Also try them locally!

  • wp core
  • wp import
  • wp export
  • wp option
  • wp menu
  • wp plugin
  • wp theme
  • wp post
  • wp user
  • wp site
  • wp super-admin
  • wp role
  • wp cap