FreshSites fully supports WP-CLI

Posted on 30/07/2019 by Jamie Martin
FreshSites fully support WP-CLI (WordPress Command Line Interface).

What exactly is WP-CLI and what can it do?

WordPress CLI, as mentioned, is the command-line interface for WordPress. It is extremely feature rich, and it's available not only on our Managed WordPress hosting servers but also our shared WordPress hosting servers.

Many of the features of the command line interface can be found within the WordPress admin web interface, but there are a few lesser known features which are command line only (unless you use a plugin to add the functionality in the web interface).

Some examples are;

Install a plugin:

wp plugin install <plugin name>

You can also use the optional --activate switch to automatically activate the plugin once it's installed.

Update a plugin:

wp plugin update <plugin name>

There is also the option of using --all instead of the plugin name, this will update all plugins which have updates available (excluding premium plugins).

The plugin command can also activate wp plugin activate <plugin name> or deactivate wp plugin deactivate <plugin name> plugins - replace the word plugin with theme to perform the same commands for themes!

wp plugin deactivate <plugin name> plugins - replace the word plugin with theme to perform the same commands for themes!

Run a search and replace on the database:

wp search-replace 'oldstring' 'newstring'


Great for updating the database for example when moving a site to a different URL:

wp search-replace 'oldurl.com' 'newurl.com'


Or for updating all URL's in WordPress to use HTTPS

wp search-replace 'http://' 'https://'

Gain access to your WordPress website when you've forgotten your admin login:

Have you ever locked yourself out of your WordPress site by forgetting your password, and no longer have access to the email address linked to it? You can get yourself back in using WP-CLI (or via phpMyAdmin, but that comes with more risks).

There are 2 options;

Create a new user with admin capabilities;

wp user create YourUsername your@email.address --role=administrator

this will create a new user and generate a password for you.

Update an existing admin user;

wp user list

This will show you a list of existing users - locate the username you wish to change the password for, and make note of the ID, you'll need it in the next step

wp user update <your user ID> --user_pass=<new password>

You'll then be able to gain access back to your account using your new password.

Delete WordPress Transients;

This is something that CAN'T be done from within the WordPress admin area by default, although it can be achieved with a plugin. To deleted WordPress Transients using the wp-cli, run the following command:

wp transient delete --all

This will delete all WordPress transients.

The possibilities with WordPress CLI are endless, so if you would like a full list of commands, you can check them out via the command line interface itself:

wp help

or for further information on a specific command:

wp help <command>

Alternatively, you can check out the full list of commands on the WordPress.org developer site at https://developer.wordpress.org/cli/commands/

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

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

© Copyright 2019 FreshSites Limited. Registered in England and Wales no. 7812509
Website Design by Pyxal
FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites FreshSites fully supports WP-CLI | FreshSites