wp
Manage WordPress websites from the command line
TLDR
Print information about the operating system, shell, PHP, and WP-CLI (wp) installation
Update WP-CLI
Download a fresh WordPress installation to current directory, optionally specifying the locale
Create basic wpconfig file (assuming database on localhost)
Install and activate a WordPress plugin
Replace all instances of a string in the database
Import the contents of a WordPress Extended RSS (WXR) file
SYNOPSIS
wp command [subcommand] [arguments] [options]
PARAMETERS
help
Displays help information for a command or subcommand.
info
Provides information about the WP-CLI environment.
cli
Manages WP-CLI itself (e.g., update, version).
core
Manages the WordPress core (e.g., update, install).
plugin
Manages WordPress plugins (e.g., install, activate).
theme
Manages WordPress themes (e.g., install, activate).
post
Manages WordPress posts (e.g., create, update).
user
Manages WordPress users (e.g., create, update).
db
Manages the WordPress database (e.g., export, import).
option
Manages WordPress options (e.g., get, update).
--path=path
Path to the WordPress installation.
--url=url
Pretend request comes from given URL. In multisite, this argument is how the target site is specified.
Ex: --url=example.com/path/to/site
--require=path
Load PHP file before running the command (may be used more than once).
Ex: --require=/path/to/my-plugin.php
--version
Show WP-CLI version.
DESCRIPTION
wp is the command-line interface for WordPress. It allows you to manage many aspects of WordPress installations, without using a web browser. You can update plugins, install themes, import content, manage users, and much more. wp is a powerful tool for developers and system administrators who need to automate WordPress management tasks. It provides a consistent and scriptable way to interact with WordPress, making it easier to deploy, update, and maintain WordPress sites at scale. It streamlines development workflows, reduces manual interventions, and helps in maintaining consistency across multiple installations.
The goal is to make wp-cli the standard for managing WordPress installations from the command line. It abstracts away the complexities of dealing with the WordPress database and core files directly.
CAVEATS
wp requires PHP and access to the WordPress database. You need to have appropriate permissions to execute commands. Some commands may require elevated privileges. Ensure that your WordPress installation is properly configured for WP-CLI to function correctly.
CONFIGURATION
WP-CLI can be configured using a wp-cli.yml or wp-cli.json file in the WordPress root directory, or in a global configuration directory. This allows you to customize the behavior of WP-CLI and set default values for options.
EXTENSIBILITY
WP-CLI is highly extensible. You can create custom commands to automate specific tasks or integrate with other systems. This makes it a flexible tool for a wide range of WordPress management scenarios.
DEBUGGING
Use the `--debug` flag for detailed output during command execution which can be useful to troubleshoot and understand any error.
HISTORY
WP-CLI was initially developed by Andreas Creten and has since been maintained by a community of contributors. It has become an essential tool for WordPress developers and administrators, especially for automating tasks and managing large-scale WordPress deployments. The development focused on providing a consistent and extensible command-line interface for WordPress, allowing for efficient management and scripting of WordPress-related tasks.
Over time, the tool has evolved to support more commands and features, making it a comprehensive solution for WordPress management.