How to Use Wordpress-Cli


Tutorials - Tutorials

User Rating: / 0

WP-Cli is a command line interface which allows the users to manage their WordPress web sites from the command prompt. Upgrades can be performed, backups can be generated, new posts can be published and most of the regular admin actions can be performed with a set of commands.

In this tutorial we will explain how to use the WP command line interface in order to complete regular administrative tasks like upgrades, database backup creation, plugins and themes installations and removals, publishing and deleting posts, changing site's URL settings and getting help on chosen commands. Note that WP-Cli requires an SSH access.

List the Available WP-Cli Commands

First, we will start with the instructions on how to list the available commands and get detailed help for each one of them.

To list all the commands write wp help or just wp.

The following list will be shown:

Available commands:wp core [download|config|install|install_network|version|update|update_db]
wp db [create|drop|optimize|repair|connect|cli|query|export|import]
wp eval-file
wp eval
wp export [validate_arguments]
wp generate [posts|users]
wp home
wp option [add|update|delete|get]
wp plugin [activate|deactivate|toggle|path|update|uninstall|delete|status|install]
wp post-meta [get|delete|add|update]
wp post [create|update|delete]
wp theme [activate|path|delete|status|install|update]
wp transient [get|set|delete|type]
wp user-meta [get|delete|add|update]
wp user [list|delete|create|update]

See 'wp help ' for more information on a specific command.

Global parameters:
--user=set the current user
--url=set the current URL
--path=set the current path to the WP install
--require=load a certain file before running the command
--versionprint WP-Cli version

If you want to get detailed documentation, for example, for the wp db export command, enter the code listed below:

wp help db export

The result will be as follows:

wp-db-export - Export the WordPress database using mysqldump.
wp db export [file]
file: The name of the export file. If omitted, it will be ´{dbname}.sql´

Now we will proceed with the regular management tasks.

Update WordPress via WP-Cli

First, we will show how to update the core files of your web site. We will check the current version which we have:

wp core version

Obviously it is outdated. In order to use the latest scripts features and have all the vulnerabilities in the older versions patched we should always use the latest stable releases for our web site applications. Using WP-Cli we will complete the upgrade with a single command:

Downloading update from

Update WordPress Plugins using WP-Cli

The update of the core files and the database are not always enough. If we have integrated external plugins and/or themes we should take care of their upgrade. We need to check the status of the installed extensions:

wp plugin status

Installed plugins:
UI akismet
I hello
UA jetpack
A limit-login-attempts
A SGCachePress

Legend: I = Inactive, A = Active, M = Must Use, U = Update Available

We have 5 plugins integrated in our sample installation. There are upgrades for two of them. We will complete the upgrades through the following commands:

Downloading update from
Downloading update from

Install and Activate WordPress Plugins & Themes via WP-Cli

To install and activate a new plugin run the commands listed below:

  • wp plugin install Plugin_Name
  • wp plugin activate Plugin_Name

You should replace the "Plugin_Name" string with the exact plugin name.

If you do not need a plugin you can remove it through the following action:

wp plugin uninstall Plugin_Name

Next, we will check the themes:

wp theme status
Installed themes:
UA twentyeleven
UI twentyten
I twentytwelve

Legend: I = Inactive, A = Active, U = Update Available

To update all the themes the following command should be executed:

Downloading update from

The themes can be installed, activated and uninstalled in a similar way to the plugins:

  • wp theme install Theme_Name
  • wp theme activate Theme_Name
  • wp theme delete Theme_Name

The "Theme_Name" string should be replaced with the actual theme name.

The activation will make the chosen theme the default one for your WordPress installation.

Other Tasks you Can do With WP-Cli

We can even write posts directly from the command line. The creation of a sample post on a new page is illustrated below:

wp post create --post_type=page --post_status=publish --post_title='My test post' --post_content='This is a test post'Success: Created post 4.

If we do not need a certain post we can easily delete it:

wp post delete 3 --forceSuccess: Deleted post 3.

Once we have our script upgraded and the content set we can generate a database backup:

wp db exportSuccess: Exported to user_wp790.sql

If the web master decides to change the primary domain for the WordPress web site he/she can easily update the corresponding URL options:

wp option update home

More details on WP cli can be found through the help command and the project's home page.

About Us

Royal Developer Top three Web Designing and Web Development Company in Dehradun, Uttarakhand, India. Royal Developer Best SEO Company in Dehradun takes pride in its philosophy of 'Employee First' which empowers to create a real value for the customers. Royal Developer can offer Best and cheap Website Development Software Development & SEO Services. We are the Best service Provider of SEO, SEM, SMO Services Company in Uttarakhand. Web Designing Course in Dehradun, Web Designing Classes in Dehradun, Web Design Training Institute in Dehradun, Web designing institute in dehradun, Best institute for web designing in dehradun, Web development training in dehradun, Web development course in dehradun, Web Designing Training in Dehradun.


- Contact Information - 

Add : RDIT Services Pvt Ltd, 3rd Floor, RGM Plaza, Above Chandu Canteen,
          23 Chakrata Road, Dehradun - 248001, Uttarakhand, India

Email : 


 : +91 8171200108, +91 8979462451,
                                  +91 7895753921

Quick Enquiry Form

Enter your full name

Enter your valid email address

Enter your correct mobile number

Invalid Input

Your Message
Invalid Input

Enter Code
Enter Code
  RefreshInvalid Input


You are here: Home Tutorials How to Use Wordpress-Cli