How to Manage WordPress With WP-CLI

WP-CLI is a set of command-line tools for managing WordPress installations on a server. It allows the WordPress admin users to carry out different administrative tasks without actually using a web browser. This management through the command line interface allows the users to manage their WordPress websites by executing a set of defined commands. The scope of the tasks mainly includes upgrades, taking database backups, publishing new posts, and much more. WP-CLI requires SSH access to connect to the respective application on the server.

In order to have a better understanding, we have listed below some of the basic WP-CLI commands. We will be using a few of the following commands:

  • 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]

We will explain some of these in greater detail below.

You must first connect to your server via SSH. If you have never done it yet, the following KBs will help:

  • How to Launch an SSH Terminal from Cloudways Platform

  • How to Connect to Your Server Using SSH

With an SSH session open, we can now move to WP-CLI itself.

Managing WordPress Plugins via WP-CLI

In this snapshot, we see how plugins can be managed through the WP-CLI interface. Here we have used the plugin status, activate, and deactivate functions. However, other functions can also be used. For reference:

wp plugin [activate|deactivate|toggle|path|update|uninstall|delete|status|install]

Listing All Available WP-CLI Commands

Typing wp or wp help will show the entire list of the WP-CLI commands that can be used to perform management/administrative tasks.

Checking Version and Updating WP Core

Since our version is already updated to the latest, the appropriate version is shown.

You can also manage users using WordPress CLI so Click Here to learn how.

Leave a Comment