wp cli

Reviews current WP-CLI info, checks for updates, or views defined aliases.

Subcommands

CommandDescription
wp cli aliasRetrieves, sets and updates aliases for WordPress Installations.
wp cli cacheManages the internal WP-CLI cache.
wp cli check-updateChecks to see if there is a newer version of WP-CLI available.
wp cli cmd-dumpDumps the list of installed commands, as JSON.
wp cli completionsGenerates tab completion strings.
wp cli has-commandDetects if a command exists.
wp cli infoPrints various details about the WP-CLI environment.
wp cli param-dumpDumps the list of global parameters, as JSON or in var_export format.
wp cli updateUpdates WP-CLI to the latest release.
wp cli versionPrints WP-CLI version.

Examples

bash
# 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.

# Clear the internal WP-CLI cache.
$ wp cli cache clear
Success: Cache cleared.

wp cli alias

Retrieves, sets and updates aliases for WordPress Installations.

Aliases are shorthand references to WordPress installs. For instance, @dev could refer to a development install and @prod could refer to a production install.

Subcommands

CommandDescription
wp cli alias addCreates an alias.
wp cli alias deleteDeletes an alias.
wp cli alias getGets the value for an alias.
wp cli alias is-groupCheck whether an alias is a group.
wp cli alias listLists available WP-CLI aliases.
wp cli alias updateUpdates an alias.

Examples

bash
# List alias information.
$ wp cli alias list
---
@all: Run command against every registered alias.
@local:
  user: wpcli
  path: /Users/wpcli/sites/testsite

# Get alias information.
$ wp cli alias get @dev
ssh: [email protected]:12345/home/dev/

# Add alias.
$ wp cli alias add @prod --set-ssh=login@host --set-path=/path/to/wordpress/install/ --set-user=wpcli
Success: Added '@prod' alias.

# Update alias.
$ wp cli alias update @prod --set-user=newuser --set-path=/new/path/to/wordpress/install/
Success: Updated 'prod' alias.

# Delete alias.
$ wp cli alias delete @prod
Success: Deleted '@prod' alias.

wp cli cache

Manages the internal WP-CLI cache.

Subcommands

CommandDescription
wp cli cache clearClears the internal cache.
wp cli cache prunePrunes the internal cache. Removes all cached files except for the newest version of each one.

Examples

bash
# Remove all cached files.
$ wp cli cache clear
Success: Cache cleared.

# Remove all cached files except for the newest version of each one.
$ wp cli cache prune
Success: Cache pruned.

wp cli check-update

Checks 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.

Synopsis

bash
wp cli check-update [--patch] [--minor] [--major] [--field=<field>] [--fields=<fields>] [--format=<format>]

Parameters

ParameterDescription
[--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,status,requires_php.
[--format=<format>]Render output in a particular format. Default: table. Options: table, csv, json, count, yaml

Examples

bash
# 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 |
+---------+-------------+-------------------------------------------------------------------------------+

wp cli cmd-dump

Dumps the list of installed commands, as JSON.

Synopsis

bash
wp cli cmd-dump

Examples

bash
$ wp cli cmd-dump
{"name":"wp","description":"Manage WordPress through the command-line.",...

wp cli completions

Generates tab completion strings.

Synopsis

bash
wp cli completions --line=<line> --point=<point>

Parameters

ParameterDescription
--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

bash
$ wp cli completions --line='wp eva' --point=100
eval
eval-file

wp cli has-command

Detects if a command exists.

This command 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.

Synopsis

bash
wp cli has-command <command_name>...

Parameters

ParameterDescription
<command_name>...The command to check.

Examples

bash
# 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

# Install a WP-CLI package if not already installed
$ if ! $(wp cli has-command doctor); then wp package install wp-cli/doctor-command; fi

wp cli info

Prints 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
  • WP-CLI root dir
  • WP-CLI global config
  • WP-CLI project config
  • WP-CLI version

Synopsis

bash
wp cli info [--format=<format>]

Parameters

ParameterDescription
[--format=<format>]Render output in a particular format. Default: list. Options: list, json

Examples

bash
$ 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

wp cli param-dump

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

Synopsis

bash
wp cli param-dump [--with-values] [--format=<format>]

Parameters

ParameterDescription
[--with-values]Display current values also.
[--format=<format>]Render output in a particular format. Default: json. Options: var_export, json

Examples

bash
$ wp cli param-dump --format=var_export
array (
  'path' =>
  array (
    'runtime' => '=<path>',
    'file' => '<path>',
    ...

wp cli update

Updates 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.

Synopsis

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

Parameters

ParameterDescription
[--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.
[--insecure]Retry without certificate validation if TLS handshake fails.

Examples

bash
$ wp cli update
You are currently using WP-CLI 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.

wp cli version

Prints WP-CLI version.

Synopsis

bash
wp cli version

Examples

bash
$ wp cli version
WP-CLI 0.24.1