Even though WordPress’ admin dashboard is intuitive and comprehensive, it can also be time-consuming and cumbersome to use.
Sometimes, it may take ages to get to the feature you want or for pages to load.
This is where WP-CLI – the WordPress Command Line Interface, comes into play.
With WP-CLI, you can have direct control over your projects, by using a few simple commands.
WP-CLI is now fully supported on our cloud hosting platform, and on all dedicated servers and virtual servers that use the Web Hosting Control Panel.
What is WP-CLI?
As an extension of both WordPress and the command line interface for Unix systems, WP-CLI allows users to manage any WordPress installation via text commands.
This simple command line tool makes almost any task you can complete on your website’s back end much quicker.
For example, if you want to install a plugin, instead of navigating through menus and search results screens, you can simply type in the following line of code:
wp plugin install user-switching --activate
In the command line example above, the User Switching plugin will be installed and activated.
How to use WP-CLI?
To take advantage of WP-CLI, you will need to have SSH access to your account with us.
You can use both the Web SSH interface that we offer or any terminal client of your choosing.
Once you are connected to your account, simply navigate to the folder of your WordPress installation.
NOTE: If WordPress is installed in /WordPress and not in the root folder for your domain, you will have to go into the /wordpress folder.
From there, you can type in wp –info. This should output something similar to:
$ wp --info
OS: Linux 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64
Shell: /usr/bin/zsh
PHP binary: /usr/bin/php8.1
PHP version: 8.1.0
php.ini used: /etc/php/8.1/cli/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
SQL modes:
WP-CLI root dir: /home/wp-cli/
WP-CLI vendor dir: /home/wp-cli/vendor
WP_CLI phar path:
WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/
WP-CLI global config:
WP-CLI project config: /home/wp-cli/wp-cli.yml
WP-CLI version: 2.7.1
If you see this, you can start using WP-CLI right away.
Some useful WP-CLI commands to get you started
With WP-CLI, you can quickly install a WordPress theme:
wp theme install twentyten
You can also activate a theme that has been installed, making it the site’s active theme:
wp theme activate twentyten
The same applies to plugins. Here is how to install WooCommerce, a popular shopping cart plugin for WordPress:
wp plugin install woocommerce
You can then activate or deactivate a plugin quickly:
wp plugin activate woocommerce
wp plugin deactivate woocommerce
You can also update your WordPress version:
wp core update
Using the following command, you can update a specific plugin:
wp plugin update woocommerce
or update all plugins at once:
wp plugin update --all
The same can be done for installed themes:
wp theme update twentyten
wp theme update --all
NOTE: You can install only themes and plugins listed in the official WordPress repository.
The number of tasks you can perform with WP-CLI is remarkable. You can also use the WP-CLI automation capability to run backups, updates, and many other repetitive manual tasks.
Working with WP-CLI is not nearly as complicated as it may look, and there are plenty of resources available if you want to learn more about it.
This includes documentation on its website, a user guide, and a number of practical examples.