WP-CLI is a powerful and extensible way to interact with WordPress from the command line.
On VIP, WP-CLI commands must be run in the command line using the VIP-CLI
vip wp command. In addition to the commands provided by WP-CLI , it is possible to write custom WP-CLI commands to accomplish tasks specific to the needs of an application on VIP.
- Not all WP-CLI commands can be run against a VIP environment.
- There is a limit of 4 WP-CLI commands that can be run on a VIP environment concurrently. This limit applies whether the environment is a WordPress single site or a WordPress multisite.
- A logged history of all Completed, Running, Cancelled or Errored WP-CLI commands can be viewed in the WP-CLI Commands panel in the VIP Dashboard.
Run a WP-CLI command with VIP-CLI
Running WP-CLI commands with VIP-CLI requires a double dash (
--) separating the arguments of the
vip command from those of the
wp command. The double dash must be included to avoid unexpected issues due to parameter conflicts.
In this example command, VIP-CLI is used to run the WP-CLI command
wp user list to retrieve the list of WordPress users from the
preprod environment of the
vip @mytestsite.preprod -- wp user list
Cancel a WP-CLI command
WP-CLI commands that are still running can be canceled by the user that initiated the command.
- From the VIP-CLI terminal: Type the keyboard abort command
Control + C.
- From the VIP Dashboard: Navigate to the WP-CLI Commands panel. Select the “Cancel” option to the right of the Running command.
Interactive shell mode
VIP-CLI includes an interactive shell mode that provides a terminal-like interface to a VIP WordPress site. The interactive shell mode is a convenient way to run multiple commands on the same environment and behaves like a standard terminal or SSH session.
- While the interactive shell looks and acts like a standard terminal, it does not currently support bash operators or commands (e.g.
xargs, variable substitution, etc). Those commands need to be run in the standard VIP-CLI format.
- Use double quotes (e.g.
"value") to pass arguments in a command in interactive shell mode to ensure that they are recognized as valid JSON. Some operations will not complete as expected if arguments are passed with single quotes (e.g.
To enter the interactive shell mode, run the VIP-CLI command:
vip @<app-name>.<env> -- wp
WP-CLI commands can then be run without the
vip @<app-name>.<env> -- argument structure.
$ vip @mytestsite.preprod -- wp mytestsite.preprod:~$ wp option get home https://example.com mytestsite.preprod:~$ wp cache delete my-cache-key my-cache-group Success: Object deleted. mytestsite.preprod:~$
--skip-plugins on VIP
On the VIP Platform, including the
--skip-plugins[=<plugins>] option with a WP-CLI command will skip the loading of all plugins—or the plugin(s) specified—and skip the loading of client-mu-plugins. VIP MU plugins, however, will still load.
Additional resources for WP-CLI
Last updated: February 09, 2024