What is WP-CLI

WP-CLI allows you to do multiple things like updating your WordPress, installing themes and plugins, without using a web browser. To take advantage of the tool you don’t need to install anything yourself. Simply login to your account via SSH, navigate to the folder of your WordPress installation and run the commands – it’s that simple!

We are super excited to announce that a new WordPress tool is now available on all our servers.

WordPress users who love command line will be happy to find WP-Cli available on all Neoxea Hosting Plans.

To learn how to use WP-CLI you can refer to our WP-CLI tutorial. Additionally, you can find a full list of WP-CLI commands on their official website.

Useful Examples

We recommend looking at the commands list, try some of them out. We will take a look at some useful options in order to get you started.

Install WordPress

We use WP-CLI a lot to set up test environments, the first step of which is a vanilla installation. Here is a list of commands we run:

wp core download
wp core config --dbname=mydbname --dbuser=mydbuser --dbpass=mydbpass --dbhost=localhost --dbprefix=whebfubwef_ --extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
wp db create
wp core install --url=http://siteurl.com --title=SiteTitle --admin_user=myusername --admin_password=mypassword [email protected]

The most recent version of WordPress is downloaded using the first command. The second command sets up the config file with the database access and some additional PHP at the end. The additional constants make sure we have our debugging options on for testing.

The third command creates the database (WP-CLI uses the database access info from the config file) and finally, we install WordPress using a couple of parameters.

Re-install WordPress Core

You can also reinstall WordPress core using WP-CLI. The following command would download WordPress core without the default themes and plugins.

wp core download --skip-content --force
List Plugins

To get a list of current plugins installed on a website simply use the following command. In this example, you can see we have the Akismet and Yoast SEO plugin installed. It will also return the status (active/deactivated), if there is an update available, and the current version.

wp plugin list
Install Plugins

To install multiple plugins you can simply add parameters. Here’s an example that downloads and activates 2 plugins:

wp plugin install akismet wordpress-seo --activate
Update Plugins

You can also manually update WordPress plugins. Example below:

wp plugin update akismet wordpress-seo
Delete Transients

You can even delete and clear out one or all transients using the following command.

wp transient delete --all
Delete Revisions

On large sites, WordPress revisions can add up very quickly to hundreds or thousands of rows in your database which are not needed. You can delete post revisions with WP-CLI. Here is an example of the command:

wp post delete $(wp post list --post_type='revision' --format=ids)
Change WordPress URL

There are many reasons why you might need or want to change your WordPress URL. Perhaps you are changing domains, moving to a subdomain, updating from www to non-www, moving files around, or even migrating from HTTP to HTTPS. Whatever the case may be, you can use easily use the wp option update command for this. Here is an example below:

wp option update home 'http://example.com'
wp option update siteurl 'http://example.com'

Save time and money, plus make your website go faster with our next-generation cloud platform available in every Managed WordPress plan. This includes a high-performance web server, DDoS protection, malware and email spam mitigation, a free cache plugin, and Linode’s fastest AMD CPU machines. Get started with no long-term contracts, free migrations, and a 45-day money-back guarantee.
Check out our plans or talk to sales to find the right plan for you.