WordPress is a popular open-source content management system that creates beautiful websites and blogs. WordPress is the most trusted CMS, as almost 64.2 percent of websites are built using it. The ecosystem of WordPress with the large pool of themes and plugins makes it the top choice among website developers who like to build sites with CMS functionality.
WordPress Command Line Interface (CLI)
Its interface is shell-based, allowing developers to perform WordPress administrative tasks that could have been otherwise only possible through the admin dashboard. Wp-admin is a backend web-based user interface to interact with plugins, posts, pages, and themes.
In other words, WP-CLI is a command-line utility that helps developers to perform complex tasks by typing single word commands from the shell and making tasks super fast without even login into the admin panel.
Improving the speed of execution for database backups, files access, theme and plugin management, installation, and other technical management must be considered among WordPress web developers. In a nutshell, using WP-CLI WordPress, developers can work by spending less time on such tasks giving them additional time to work on the other development-related work for WordPress.
Let's dive deeper to understand what WP-CLI is and how it works.
WordPress CLI runs on the command line, and to use WP-CLI, you need to have shell access to your web server. In today most of the hosting providers offer shell or command line access to the hosting account.
For Linux or Mac users, this program is called Terminal, and on Windows, it is called command prompt. On a Windows machine, sometimes, to work with remote servers, you might need to install putty.
You need to make sure your environment is compatible and has the following items in place:
using SSH and configure it with the necessary settings. Run the following command to download
in your root directory:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Confirm if the download was successful using
php wp-cli.phar --info
executable to it can run by simply
chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp
After execution of all commands above, we can ensure, wp-cli is installed properly by running the command
In case of successful installation, you will see the currently installed version of WP-CLI on your command prompt. An Alternate way to install CLI is using composer.
WordPress CLI, managing your WordPress is at your fingertips, and it has built-in help that can be invoked with
command, but you can have detailed reference of commands from the official documentation. Here are some of the important commands of
to illustrate how fast certain tasks can be performed.
It will return the current version of the WordPress installation.
wp core version
If a newer version is available, it will update the current version of WordPress to the latest version.
wp core update
If you want to update your WordPress installation to a specific version, you can update it with the command specified above.
wp core update --version=4.0
It will connect your current WordPress installation with the WordPress theme repository. And install the available themes to your WordPress installation with a matter of issuing one single command. For example, in the above command, it will install theme TwentyTen in your WordPress.
wp theme install twentyten
This command with activate the installed theme twentyten.
wp theme activate twentyten
Just like themes, we can install and manage themes with wp-cli. The above command will install a popular woo-commerce plugin to your current WordPress installation.
wp plugin install woocommerce
To activate a woo-commerce plugin, we can use the above command.
wp plugin activate woocommerce
Similarly, to deactivate the woo-commerce plugin, we use the above command.
wp plugin activate woocommerce
No doubt, WP-CLI is a magical tool to manage WordPress applications, and I would like to add there are many more commands that are available with
, helping developers taking database backups, media backups, manage pages, posts, etc. All these speed up the overall development of WordPress sites and make management easier.