WP-CLI is the WordPress Command-Line Interface. If you manage multiple WordPress sites and are comfortable with a command line interface, WP-CLI is for you. But even if you’ve never used a CLI before, WP-CLI may still have a place in your life.
WP-CLI is installed and ready to use on all of the GreenGeeks web servers, and works on WordPress Version 3.7 or later running on PHP 5.4 or later.
Before we get into what you can do with WP-CLI, we should talk about connecting to your website in a way that allows you to use a CLI. There are a couple of ways to do that. First is a traditional command line shell that you open up on your computer. We have a step by step tutorial to help you get a shell connection up and running.
Note: When you’re first getting started with WP-CLI you may want to set up a test WordPress installation, or even a sandbox or development environment so you are free to experiment and make mistakes without causing problems on a live WordPress website.
Once you’ve established your connection (preferably to a WordPress installation that you can afford to break), here are a few useful WP-CLI commands to try.
wp plugin update –all
Downloads and updates all installed plugins to their latest version. wp plugin update documentation.
wp core update
Update your WordPress installation. Can also be used with a version flag to roll back a minor version update. For example, updated to 5.1 and something’s not quite right? Revert to the previous version with wp core update –version=5.0.4. wp core update documentation.
wp user update [email protected] –user_pass=naQRqmRa
This example (with the “user_pass” flag) resets a user password. In the example above, “[email protected]” is being given the “naQRqmRa” password. wp user update documentation.
wp core download
Downloads the latest version of WordPress (for a new installation). Can be used with wp config create, wp db create, and wp core install to do a complete WordPress set up and configuration. wp core download documentation.
wp scaffold child-theme sample-theme –parent_theme=twentysixteen
Creates a child theme folder with functions.php and style.css files. In the example above, “sample-theme” is the name of the child theme, and “twentysixteen” is the parent theme. wp scaffold child-theme documentation.
Finally, here’s a list of all WP-CLI commands.