wp cli
Reviews current WP-CLI info, checks for updates, or views defined aliases.
Subcommands
| Command | Description |
|---|---|
wp cli alias |
Retrieves, sets and updates aliases for WordPress Installations. |
wp cli cache |
Manages the internal WP-CLI cache. |
wp cli check-update |
Checks to see if there is a newer version of WP-CLI available. |
wp cli cmd-dump |
Dumps the list of installed commands, as JSON. |
wp cli completions |
Generates tab completion strings. |
wp cli has-command |
Detects if a command exists. |
wp cli info |
Prints various details about the WP-CLI environment. |
wp cli param-dump |
Dumps the list of global parameters, as JSON or in var_export format. |
wp cli update |
Updates WP-CLI to the latest release. |
wp cli version |
Prints WP-CLI version. |
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.
# 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
| Command | Description |
|---|---|
wp cli alias add |
Creates an alias. |
wp cli alias delete |
Deletes an alias. |
wp cli alias get |
Gets the value for an alias. |
wp cli alias is-group |
Check whether an alias is a group. |
wp cli alias list |
Lists available WP-CLI aliases. |
wp cli alias update |
Updates an alias. |
Examples
# 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
| Command | Description |
|---|---|
wp cli cache clear |
Clears the internal cache. |
wp cli cache prune |
Prunes the internal cache. Removes all cached files except for the newest version of each one. |
Examples
# 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
wp cli check-update [--patch] [--minor] [--major] [--field=<field>] [--fields=<fields>] [--format=<format>]
Parameters
| Parameter | Description |
|---|---|
[--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
# 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
wp cli cmd-dump
Examples
$ wp cli cmd-dump
{"name":"wp","description":"Manage WordPress through the command-line.",...
wp cli completions
Generates tab completion strings.
Synopsis
wp cli completions --line=<line> --point=<point>
Parameters
| Parameter | Description |
|---|---|
--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
$ 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
wp cli has-command <command_name>...
Parameters
| Parameter | Description |
|---|---|
<command_name>... |
The command to check. |
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
# 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
wp cli info [--format=<format>]
Parameters
| Parameter | Description |
|---|---|
[--format=<format>] |
Render output in a particular format. Default: list. Options: list, json |
Examples
$ 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
wp cli param-dump [--with-values] [--format=<format>]
Parameters
| Parameter | Description |
|---|---|
[--with-values] |
Display current values also. |
[--format=<format>] |
Render output in a particular format. Default: json. Options: var_export, json |
Examples
$ 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
wp cli update [--patch] [--minor] [--major] [--stable] [--nightly] [--yes] [--insecure]
Parameters
| Parameter | Description |
|---|---|
[--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
$ 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
wp cli version
Examples
$ wp cli version
WP-CLI 0.24.1