1. Home
  2. WordPress Tutorials
  3. How to use WP CLI for your WordPress Website

How to use WP CLI for your WordPress Website

WP CLi stands for WordPress Command Line Interface (CLi). It is a much faster and simpler way of accomplishing most of the admin activities including tasks like generating backups, publishing posts, performing upgrades and many more. All your tasks can be done with the help of few sets of commands. All you have to remember is that to work with WP CLi you will need an access to SSH. You can get this access easily by enabling the option in the Advanced Section of the cPanel. This interface is clearly used to manage the WordPress installations. GreenGeeks supports WP CLi on its shared, reseller, vps and dedicated hosting services.

Basic System Requirements

Before opting for the WordPress Command Line Interface it is very much necessary to understand and check for the basic system requirements that are necessary for it. You can find the requirement list below:

  • Operating System: Environment similar to UNIX such as OS X, Linux, FreeBSD, Cygwin
  • Scripting Language: PHP 5.3.2 or later
  • Version: WordPress Version 3.4 or later


You can install the WordPress Command Line Interface by executing the following command in a SSH terminal
# cd ~
# mkdir wp-cli
# cd wp-cli
# curl -k -L https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > wp-cli.phar
# echo ‘alias wp=”php /home/YOUR_USERNAME/wp-cli/wp-cli.phar’ >> ~/.bashrc
# source ~/.bashrc

This will install WP-CLI and set the alias for the command to “wp”, you will prepend this to each of the commands below.

Basic Commands for WP CLi

Some of the very basic commands used in the WordPress Command Line Interface are listed below with their purpose:

  • blog: Manages your blogs in a multisite installation.
  • cache: Manages your object cache.
  • cap: Manages all the capabilities of your users.
  • comments: Manages all your user comments.
  • core: Manages all the WordPress tasks like downloading, installing, updating etc.
  • db: Performs all your basic database operations.
  • eval: Executes the arbitrary PHP code after WordPress is loaded.
  • eval-file: Loads and executes PHP code after WordPress is loaded.
  • export: Exports your WordPress content to WXR file.
  • help: Provides help on various WordPress topics.
  • media: Controls your media library along with its attachments.
  • option: Manages your options in WordPress.
  • plugin: Manages your WordPress Plugins.
  • post: Manages all your WordPress Posts.
  • post-meta: Manages all your custom posts in WordPress.
  • rewrite: Manages the rules related to rewrite options.
  • roles: Manages the roles of your WordPress users.
  • scaffold: Generates the code for taxonomies and post types in your WordPress site.
  • search-replace: Searches and replaces the strings in your WordPress.
  • shell: Interactive console for PHP scripting.
  • term: Manages your WordPress terms.
  • theme: Manages your WordPress themes
  • transient: Manages all the transients in WordPress.
  • user: Manages all your site users.
  • user-meta: Manages the custom fields of your WordPress users.

Updating WP Core

WordPress Core upgradation is very much necessary whenever there is a new version release for WordPress in the market. The upgrade process might seem to be a cumbersome one if you handle it in the regular manner with the GUI. Using a WP CLi it is much easier irrespective of whether you perform a single site or multi-site upgrade. The steps involved in the upgrade process are listed below:

  1. Version Check: Check the existing version of WordPress being used on your site. For that, go to the WordPress directory where you can find the “wp-login.php” and execute the “wp core version” command. You can go ahead with your upgrade process if your existing version is lower than the current WP version available in the market.
  2. Database Backup: Before commencing with upgrade process, always take a backup of your database to be on a safer side. To take a back-up, execute the command “wp db export”.
  3. Upgrade Version: Run the “wp core update” command to start with upgrade process and here you are with the latest WordPress Version running on your site.

In case, you have a multi-site WordPress Installation then you can just replace the path i.e., “/usr/local/web/[site-name]/htdocs” at every root of your live WordPress installations.

Handling Plugins and Themes

You can manage your WordPress plugins and themes by executing simple commands. Some of the commands used to manage the plugins are listed below:

  • wp plugin status: Lists all your plugins along with their current active or inactive status.
  • wp plugin update restricted-site-access: Updates a single plugin of your choice.
  • wp plugin update-all: Updates all your existing plugins.
  • wp plugin activate <plugin name>: Activates a particular plugin.
  • wp plugin deactivate <plugin name>: Deactivates a particular plugin.

You can just replace the word plugin with theme to perform the similar activities with themes.

WordPress Command Line Interface can be used to manage and handle all your WordPress related tasks using simple command lines.

Author: Alex G.

Updated on February 13, 2018

Was this article helpful?

Related Articles


  1. I think the quotation marks in the tutorial are causing the `echo` command to not work properly when copying and pasting.

    Try typing it out by hand if you get the message `-bash: alias: command not found`

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.