Welcome to WP-CLIWP-CLIWP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/https://make.wordpress.org/cli/!
WP-CLI is the official command line tool for interacting with and managing your WordPress sites.
Congratulations! You’ve installed WP-CLI for the first time, and are ready to level-up your use of WordPress. This page contains a brief introduction to WP-CLIWP-CLIWP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/https://make.wordpress.org/cli/ with some example usage.
WP-CLI is a command line interface for WordPress. The project’s goal is to offer a complete alternative to the WordPress admin; for any action you might want to perform in the WordPress admin, there should be an equivalent WP-CLI command.
For instance, because you can install a pluginPluginA plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party from the WordPress admin, you can also install a plugin with WP-CLI:
$ wp plugin install akismet
Installing Akismet (3.1.8)
Downloading install package from https://downloads.wordpress.org/plugin/akismet.3.1.8.zip...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
And, because you can also activate plugins from the WordPress admin, you can activate a plugin with WP-CLI:
One key difference between using the WordPress admin and WP-CLI: performing any action takes many fewer clicks. As you become more familiar with the command line, you’ll notice performing a given task with WP-CLI is generally much faster than performing the same task through the WordPress admin. Investing time upfront into learning how to better use WP-CLI pays dividends in the long term.
Throughout your usage of WP-CLI, you’ll hear certain terms used over and over again.
For instance, a command is an atomic unit of WP-CLI functionality. wp plugin install is one such command, as is wp plugin activate. Commands represent a name (e.g. ‘plugin install’) and a callback, and are registered with WP_CLI::add_command() (doc).
The synopsis defines which positional and associative arguments a command accepts. Let’s take a look at the synopsis for wp plugin install:
In this example, <plugin|zip|url>... is the accepted positional argument. In fact, wp plugin install accepts the same positional argument (the slug, ZIP, or URLURLA specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org of a plugin to install) multiple times. [--version=<version>] is one of the accepted associative arguments. It’s used to denote the version of the plugin to install. Notice, too, the square brackets around the argument definition; square brackets mean the argument is optional.
WP-CLI also has a series of global arguments which work with all commands. For instance, including --debug means your command execution will display all PHPPHPPHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. https://www.php.net/manual/en/preface.php. errors, and add extra verbosity to the WP-CLI bootstrap process.
Use wp plugin update --all (doc) to update all plugins to their latest version.
$ wp plugin update --all
Enabling Maintenance mode...
Downloading update from https://downloads.wordpress.org/plugin/akismet.3.1.11.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Downloading update from https://downloads.wordpress.org/plugin/nginx-champuru.3.2.0.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Disabling Maintenance mode...
Success: Updated 2/2 plugins.
+------------------------+-------------+-------------+---------+
| name | old_version | new_version | status |
+------------------------+-------------+-------------+---------+
| akismet | 3.1.3 | 3.1.11 | Updated |
| nginx-cache-controller | 3.1.1 | 3.2.0 | Updated |
+------------------------+-------------+-------------+---------+
Add a user as a super-admin
On multisiteMultisiteMultisite is a WordPress feature which allows users to create a network of sites on a single WordPress installation. Available since WordPress version 3.0, Multisite is a continuation of WPMU or WordPress Multiuser project. WordPress MultiUser project was discontinued and its features were included into WordPress core.https://codex.wordpress.org/Create_A_Network., use wp super-admin add (doc) to grant super admin capabilities to an existing user.
If you’ve added or changed an image size registered with add_image_size(), you may want to use wp media regenerate (doc) so your theme displays the correct image size.
wp media regenerate --yes
Found 1 image to regenerate.
1/1 Regenerated thumbnails for "charlie-gpa" (ID 4).
Success: Finished regenerating the image.
Search and replace URLs
If you’re moving a database from one domain to another, wp search-replace (doc) makes it easy to update all URL references in your database.
To see which links will be replaced in your database, use the –dry-run flag:
Wondering what’s next? Browse through all of WP-CLI’s commands to explore your new world. For more detailed information about creating custom commands, visit the WP-CLI Commands Cookbook. Or, catch up with shell friends to learn about helpful command line utilities.