WordPress

Useful WP-CLI commands

In this article we list a number of useful WP-CLI commands you can run to administer your WordPress website from terminal.

List active plugins on your WordPress site

wp plugin list --status=active

Deactivate a plugin

You can use the following command to deactivate a plugin:

wp plugin deactivate <plugin-slug>

Replace with the slug of the plugin you want to deactivate. The slug is typically the folder name of the plugin within the wp-content/plugins directory.

For example.

If you wanted to deactivate a plugin called “Hello Dolly,” whose slug is hello-dolly, you would run:

wp plugin deactivate hello-dolly

Delete a plugin

wp plugin delete pluginname

Replace pluginname with the name of your plugin you want to delete. For example, to delete the ‘hello’ plugin run the following command;

wp plugin delete hello

Activate a plugin

wp plugin activate pluginname

Replace pluginname with the name of your plugin you want to activate. For example, to activate the ‘hello’ plugin run the following command;

wp plugin activate hello

Install a plugin

wp plugin install pluginname

Replace pluginname with the name of your plugin you want to install. For example, to install the ‘hello’ plugin run the following command;

wp plugin install hello

Install and activate plugin

wp plugin install pluginname --activate

Replace pluginname with the name of your plugin you want to install and activate. For example, to install and activate the ‘hello’ plugin run the following command;

wp plugin install hello --activate

List WordPress Users

wp wp user list

Change WordPress Admin Username

Use the following command to change the username used to login to WordPress. Replace * old_username* with the username you wish to update. Replace new_username with the new user name you wish to use.

Use –dry-run option to run the search without making changes.

wp search-replace old_username new_username --dry-run

When ready run the following command to save changes. Again being sure to replace the placeholder values with your own.

wp search-replace old_username new_username

Change WordPress Admin Password

wp user update admin --user_pass=password

Disable Search Engines

To disable search engines from indexing your WordPress site using WP-CLI, you need to update the blog_public option in your WordPress database. This option controls whether search engines are allowed to index your site.

wp option update blog_public 0

Password Protect your entire WordPress site using a plugin

These steps will install and activate the “Password Protected” plugin, set the password, and enable password protection for your entire WordPress site. Replace ‘yourpassword’ with your desired password.

wp plugin install password-protected --activate
wp option update password_protected_password 'yourpassword'
wp option update password_protected_status '1'

External Resources

WordPress Developer Resources WP-CLI Commands

Was this guide helpful?

Need help with this?

Open a ticket and link to this guide so our team can see what you have tried.

View support tickets

Power your business with Ecenica Hosting

Built for WordPress and serious websites. Fast, secure and supported by real people in the UK.

Ecenica hosting services represented by a connected red route across London