WordPress at a glance
Home Handbook WP-CLI Commands

wp cli

Review current WP-CLI info, check for updates, or see defined aliases.

Commands Description
Print WP-CLI version.
Print various details about the WP-CLI environment.
Check to see if there is a newer version of WP-CLI available.
Update WP-CLI to the latest release.
Dump the list of global parameters, as JSON or in var_export format.
Dump the list of installed commands, as JSON.
Generate tab completion strings.
List available WP-CLI aliases.
Detects if a command exists

Examples

# Display the version currently installed.
$ wp cli version
WP-CLI 0.24.1

# Check for updates to WP-CLI.
$ wp cli check-update
Success: WP-CLI is at the latest version.

# Update WP-CLI to the latest stable release.
$ wp cli update
You have version 0.24.0. Would you like to update to 0.24.1? [y/n] y
Downloading from https://github.com/wp-cli/wp-cli/releases/download/v0.24.1/wp-cli-0.24.1.phar...
New version works. Proceeding to replace.
Success: Updated WP-CLI to 0.24.1.

Source code of the commands


wp cli version

Print WP-CLI version.

Usage

wp cli version 

Examples

# Display CLI version.
$ wp cli version
WP-CLI 0.24.1

wp cli info

Print various details about the WP-CLI environment.

Helpful for diagnostic purposes, this command shares:

  • OS information.
  • Shell information.
  • PHP binary used.
  • PHP binary version.
  • php.ini configuration file used (which is typically different than web).
  • WP-CLI root dir: where WP-CLI is installed (if non-Phar install).
  • WP-CLI global config: where the global config YAML file is located.
  • WP-CLI project config: where the project config YAML file is located.
  • WP-CLI version: currently installed version.

See config docs for more details on global and project config YAML files.

Usage

wp cli info [--format={format}]

You can specify global options and the following:

[--format={format}]

Render output in a particular format.
Default: list
Can be:

  • list
  • json

Examples

# Display various data about the CLI environment.
$ wp cli info
OS:  Linux 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017 x86_64
Shell:   /usr/bin/zsh
PHP binary:  /usr/bin/php
PHP version: 7.1.12-1+ubuntu16.04.1+deb.sury.org+1
php.ini used:    /etc/php/7.1/cli/php.ini
WP-CLI root dir:    phar://wp-cli.phar
WP-CLI packages dir:    /home/person/.wp-cli/packages/
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 1.5.0
menu

wp cli check-update

Check to see if there is a newer version of WP-CLI available.

Queries the Github releases API. Returns available versions if there are updates available, or success message if using the latest release.

Usage

wp cli check-update [--patch] [--minor] [--major] [--field={field}] [--fields={fields}] [--format={format}]

You can specify global options and the following:

[--patch]
Only list patch updates.
[--minor]
Only list minor updates.
[--major]
Only list major updates.
[--field={field}]
Prints the value of a single field for each update.
[--fields={fields}]
Limit the output to specific object fields. Defaults to version,update_type,package_url.
[--format={format}]

Render output in a particular format.
Default: table
Can be:

  • table
  • csv
  • json
  • count
  • yaml

Examples

# Check for update.
$ wp cli check-update
Success: WP-CLI is at the latest version.
# Check for update and new version is available.
$ wp cli check-update
+---------+-------------+-------------------------------------------------------------------------------+
| version | update_type | package_url                                                                   |
+---------+-------------+-------------------------------------------------------------------------------+
| 0.24.1  | patch       | https://github.com/wp-cli/wp-cli/releases/download/v0.24.1/wp-cli-0.24.1.phar |
+---------+-------------+-------------------------------------------------------------------------------+
menu

wp cli update

Update WP-CLI to the latest release.

Default behavior is to check the releases API for the newest stable version, and prompt if one is available.

Use --stable to install or reinstall the latest stable version.

Use --nightly to install the latest built version of the master branch. While not recommended for production, nightly contains the latest and greatest, and should be stable enough for development and staging environments.

Only works for the Phar installation mechanism.

Usage

wp cli update [--patch] [--minor] [--major] [--stable] [--nightly] [--yes]

You can specify global options and the following:

[--patch]
Only perform patch updates.
[--minor]
Only perform minor updates.
[--major]
Only perform major updates.
[--stable]
Update to the latest stable release. Skips update check.
[--nightly]
Update to the latest built version of the master branch. Potentially unstable.
[--yes]
Do not prompt for confirmation.

Examples

# Update CLI.
$ wp cli update
You have version 0.24.0. Would you like to update to 0.24.1? [y/n] y
Downloading from https://github.com/wp-cli/wp-cli/releases/download/v0.24.1/wp-cli-0.24.1.phar...
New version works. Proceeding to replace.
Success: Updated WP-CLI to 0.24.1.
menu

wp cli param-dump

Dump the list of global parameters, as JSON or in var_export format.

Usage

wp cli param-dump [--with-values] [--format={format}]

You can specify global options and the following:

[--with-values]
Display current values also.
[--format={format}]

Render output in a particular format.
Default: json
Can be:

  • var_export
  • json

Examples

# Dump the list of global parameters.
$ wp cli param-dump --format=var_export
array (
  'path' =>
  array (
	'runtime' => '=<path>',
	'file' => '<path>',
	'synopsis' => '',
	'default' => NULL,
	'multiple' => false,
	'desc' => 'Path to the WordPress files.',
  ),
  'url' =>
  array (

wp cli cmd-dump

Dump the list of installed commands, as JSON.

Usage

wp cli cmd-dump 

Examples

# Dump the list of installed commands.
$ wp cli cmd-dump
{"name":"wp","description":"Manage WordPress through the command-line.","longdesc":"\n\n## GLOBAL PARAMETERS\n\n  --path=<path>\n      Path to the WordPress files.\n\n  --ssh=<ssh>\n      Perform operation against a remote server over SSH (or a container using scheme of "docker" or "docker-compose").\n\n  --url=<url>\n      Pretend request came from given URL. In multisite, this argument is how the target site is specified. \n\n  --user=<id|login|email>\n

wp cli completions

Generate tab completion strings.

Usage

wp cli completions --line={line} --point={point}

You can specify global options and the following:

--line={line}
The current command line to be executed.
--point={point}
The index to the current cursor position relative to the beginning of the command.

Examples

# Generate tab completion strings.
$ wp cli completions --line='wp eva' --point=100
eval
eval-file

wp cli alias

List available WP-CLI aliases.

Aliases are shorthand references to WordPress installs. For instance, @dev could refer to a development installation and @prod could refer to a production installation. This command gives you visibility in what registered aliases you have available.

Usage

wp cli alias [--format={format}]

You can specify global options and the following:

[--format={format}]

Render output in a particular format.
Default: yaml
Can be:

  • yaml
  • json
  • var_export

Examples

# List all available aliases.
$ wp cli alias
---
@all: Run command against every registered alias.
@prod:
  ssh: runcommand@runcommand.io~/webapps/production
@dev:
  ssh: vagrant@192.168.50.10/srv/www/runcommand.dev
@both:
  - @prod
  - @dev
menu

wp cli has-command

Detects if a command exists

This commands checks if a command is registered with WP-CLI. If the command is found then it returns with exit status 0. If the command doesn't exist, then it will exit with status 1.

Usage

wp cli has-command {command_name}...

You can specify global options and the following:

{command_name}...
The command

Examples

# The "site delete" command is registered.
$ wp cli has-command "site delete"
$ echo $?
0
# The "foo bar" command is not registered.
$ wp cli has-command "foo bar"
$ echo $?
1