Skip to main content
How to Manage WordPress With WP-CLI

Want to manage WordPress with WP-CLI? Hee’s how to launch and connect using the Cloudways Platform.

Emmad avatar
Written by Emmad
Updated over a week ago

Table of Contents

Cloudways simplifies WordPress management with its one-click installation feature, allowing users to quickly set up a WordPress site. However, managing and maintaining a WordPress application can still require various administrative tasks. This is where WP-CLI (WordPress Command Line Interface) comes in handy. WP-CLI provides a powerful set of command-line tools to streamline the management of your WordPress sites hosted on Cloudways.

In this guide, we’ll walk you through how to use WP-CLI to manage your WordPress application effectively.

Introduction to WP-CLI

WP-CLI is a command-line tool that allows you to manage WordPress applications without accessing the WordPress admin dashboard. With WP-CLI, you can perform a wide range of tasks, such as updating plugins, managing themes, running database queries, and more. For Cloudways users, this means you can manage your WordPress site more efficiently, directly from the server, using SSH.

How to Manage WordPress With WP-CLI

Cloudways makes it easy to start using WP-CLI with your WordPress site. Before you begin, you need to establish an SSH connection to your application. If you haven’t done this yet, refer to the following guides:

Once you have established an SSH connection, you can start using WP-CLI to manage your WordPress application.

Managing WordPress Plugins via WP-CLI

One of the most common tasks for WordPress administrators is managing plugins. WP-CLI provides a straightforward way to handle plugin management, which can save you a lot of time compared to the traditional method of navigating through the WordPress admin dashboard.

Basic Plugin Commands:

Action

Command

Description

List Plugins

wp plugin list

Use this command to display a list of all plugins installed on your WordPress site, along with their status (active/inactive).

Activate a Plugin

wp plugin activate [plugin-name]

Activate a specific plugin. Replace [plugin-name] with the actual name of the plugin you want to activate.

Deactivate a Plugin

wp plugin deactivate [plugin-name]

Deactivate a specific plugin using its name.

Install a Plugin

wp plugin install [plugin-name]

Download and install a plugin from the WordPress Plugin Repository. Replace [plugin-name] with the plugin's name.

Update a Plugin

wp plugin update [plugin-name]

Update a specific plugin to the latest version available.

Example Use Case:
If you need to update all plugins on your WordPress site to their latest versions, simply run:

wp plugin update --all

This command will update all installed plugins, ensuring they are up-to-date with the latest features and security patches.

Listing All Available WP-CLI Commands

To see a full list of available WP-CLI commands, use:

wp help

or just

wp

This will provide a comprehensive list of commands available for managing your WordPress site, along with brief descriptions of each command.

Checking Version and Updating WordPress Core

Keeping your WordPress core up-to-date is crucial for security and performance. WP-CLI makes it easy to check the current version and update WordPress.

Action

Command

Description

Check WordPress Version

wp core version

This command displays the current version of WordPress installed on your site.

Update WordPress Core

wp core update

This command updates WordPress to the latest version available.

Example Use Case:
When a new version of WordPress is released, you can quickly update your site by running:

wp core update

This command ensures your site is running the latest, most secure version of WordPress.

Commonly Used WP-CLI Commands and Their Use Cases

Here are some commonly used WP-CLI commands that can streamline your WordPress management tasks:

Action

Command

Description

Create a New Post

wp post create --post_title="Your Post Title" --post_status=publish

Creates a new post with the specified title and publishes it immediately.

List Posts

wp post list

Lists all posts on your site, including their status and post type.

List Users

wp user list

Displays a list of all users registered on your WordPress site.

Get an Option Value

wp option get blogname

Retrieves the value of the specified WordPress option.

Update an Option Value

wp option update blogname "New Blog Name"

Updates the value of a WordPress option.

Export Database

wp db export

Exports the entire database to a SQL file.

Import Database

wp db import filename.sql

Imports a database from a SQL file.

Example Use Case:
If you need to reset a user password, you can use the following command:

wp user update username --user_pass=newpassword

This command updates the password for the specified user, providing a quick way to manage user accounts.

WP-CLI is an essential tool for managing your WordPress application on Cloudways. By leveraging the power of WP-CLI, you can automate routine tasks, manage your site more efficiently, and maintain greater control over your WordPress environment. Whether it’s updating plugins, managing users, or optimizing the database, WP-CLI provides the flexibility and power to handle it all from the command line.

Tip
For more detailed information on WP-CLI commands, refer to the official WP-CLI documentation or reach out to Cloudways Support.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?