How to Manage WordPress With WP-CLI: Complete Guide (UAE)

How to Manage WordPress With WP-CLI

Managing WordPress through the dashboard is convenient, but many administrative tasks can be performed faster with WP-CLI. It provides a command-line interface for WordPress, allowing you to manage core, plugins, themes, users, settings, content, maintenance tasks, and more without relying on the browser.

WP-CLI is particularly useful for WordPress hosting users, developers, and administrators who manage multiple websites or need to perform repetitive tasks through SSH or another command-line environment. The current WP-CLI project supports WordPress management through a large collection of built-in commands and can be extended with additional packages.

This guide focuses on practical WP-CLI commands for managing an existing WordPress website.

What You Need Before Using WP-CLI

What You Need Before Using WP-CLI

Before using WP-CLI, you generally need:

  • A working WordPress installation
  • Command-line or SSH access
  • WP-CLI installed and available as the wp command
  • Appropriate access to the WordPress files and database
  • A compatible PHP environment

The current WP-CLI documentation lists PHP 7.2.24 or later as the minimum requirement. However, PHP 7.x is outdated, so check your hosting environment and use a currently supported PHP release whenever your WordPress installation, plugins, and themes allow it.

You should also keep WP-CLI itself current. Check its version with:

wp cli version

Check for a newer release with:

wp cli check-update

If you installed WP-CLI using the recommended Phar method, you can update it with:

wp cli update

The exact update method can depend on how WP-CLI was installed.

Understanding WP-CLI Commands

Most WP-CLI commands follow this structure:

wp <command> <subcommand> [options]

For example:

wp plugin list

Here, plugin identifies the command group and list specifies the action.

If you are unsure about a command, use WP-CLI’s built-in help:

wp help

Or:

wp help plugin update

This is often the safest way to check available arguments before running an unfamiliar command.

Important: Replace Placeholders

Examples in documentation commonly use placeholders such as:

plugin-name

option_name

value

USER_ID

/path/to/wordpress

Do not copy these literally. Replace them with the actual plugin slug, option name, user ID, or filesystem path for your website.

Check Your WordPress Installation

Check Your WordPress Installation

Before making changes, confirm that WP-CLI is working with the correct WordPress installation:

wp core version

You can also inspect the WP-CLI environment:

wp –info

If several WordPress websites exist on the same server, specify the installation path:

wp core version –path=/home/user/public_html

The –path parameter tells WP-CLI which WordPress installation to use. Other global parameters can target a specific multisite URL or remote environment.

Manage WordPress Core

Start by checking the installed WordPress version:

wp core version

Check for available updates:

wp core check-update

Update WordPress when appropriate:

wp core update

If WordPress requires a database update:

wp core update-db

WP-CLI also provides a useful security check for WordPress core files:

wp core verify-checksums

This compares installed WordPress files against checksums published by WordPress.org and can help identify unexpected file modifications.

Best practice: Confirm that a recent backup exists before performing significant production updates.

Manage WordPress Plugins

Plugin administration is one of the most useful applications of WP-CLI.

List Installed Plugins

wp plugin list

You can also check plugin status:

wp plugin status

Install and Activate a Plugin

wp plugin install plugin-name

Activate it with:

wp plugin activate plugin-name

You can also install and activate a plugin in one operation:

wp plugin install plugin-name –activate

WP-CLI supports plugin slugs, local ZIP files, and remote ZIP URLs for installation.

Update Plugins Safely

Preview available updates first:

wp plugin update –all –dry-run

Then update all plugins:

wp plugin update –all

For more controlled maintenance, WP-CLI supports options such as –minor and –exclude for limiting which updates are applied.

For example:

wp plugin update –all –minor

You can also request concise summary output:

wp plugin update –all –format=summary

Check the command documentation for the exact options supported by your installed WP-CLI version.

Verify Plugin Checksums

For plugins hosted through WordPress.org, you can verify their files against published checksums:

wp plugin verify-checksums –all

This can help identify unexpected changes to plugin files.

Deactivate a Plugin

wp plugin deactivate plugin-name

For troubleshooting, you can temporarily deactivate all standard plugins:

wp plugin deactivate –all

Reactivate them individually after testing to help identify a plugin conflict.

Manage WordPress Themes

Manage WordPress Themes

WP-CLI provides similar commands for themes.

List installed themes:

wp theme list

Install a theme:

wp theme install theme-name

Activate a theme:

wp theme activate theme-name

Update themes:

wp theme update –all

Preview updates first:

wp theme update –all –dry-run

Avoid changing an active production theme without first confirming that the replacement is compatible with the website.

Manage WordPress Settings

WP-CLI can retrieve and change WordPress options.

For example:

wp option get siteurl

Check the home URL:

wp option get home

Update an option:

wp option update option_name value

Only change options when you understand what they control. Incorrect values can affect important WordPress functionality.

For configuration stored in wp-config.php, WP-CLI also provides the wp config command. This can be useful for controlled configuration changes, but sensitive settings should be handled carefully and tested before applying them to production.

Manage WordPress Users

Manage WordPress Users

List WordPress users:

wp user list

Create a user:

wp user create username email@example.com –role=editor

WP-CLI can also update users and their roles.

For security incidents, you can invalidate a user’s active sessions:

wp user session destroy username –all

This destroys all sessions for that user and can be useful when access needs to be revoked quickly.

Manage Posts and Pages

WP-CLI can perform basic WordPress content-management tasks.

List posts:

wp post list

Retrieve a specific post:

wp post get USER_ID

Replace USER_ID with the actual post ID.

WP-CLI also provides commands for pages, terms, taxonomies, media, and other WordPress content structures. For normal editorial work, the WordPress dashboard is usually more convenient; WP-CLI becomes valuable for repetitive or bulk operations.

Perform WordPress Maintenance

Flush Rewrite Rules

When WordPress rewrite rules need to be regenerated:

wp rewrite flush

Use this when appropriate after permalink or rewrite-related changes rather than treating it as a universal fix for WordPress URL problems.

Enable Maintenance Mode

Enable maintenance mode:

wp maintenance-mode activate

Check its status:

wp maintenance-mode status

Disable it after maintenance:

wp maintenance-mode deactivate

Search and Replace Database Content

WP-CLI can perform database search-and-replace operations, which can be useful when changing URLs or specific database values.

Preview a replacement first:

wp search-replace ‘old-domain.com’ ‘new-domain.com’ –dry-run

If the results are correct, run the operation without –dry-run.

Because this command can modify substantial amounts of database content, make sure you have a reliable backup before executing it on a production site.

For a complete website migration, use a dedicated WordPress Migration Guide rather than treating search-and-replace as a complete migration process.

Manage Multiple WordPress Sites With Aliases

Manage Multiple WordPress Sites With Aliases

If you regularly manage several WordPress installations, repeatedly typing SSH hosts and paths becomes inefficient.

WP-CLI aliases provide shortcuts such as:

wp @staging plugin list

or:

wp @production core check-update

Aliases can be defined in wp-cli.yml or your global WP-CLI configuration:

@staging:

  ssh: user@staging.example.com

  path: /var/www/html

@production:

  ssh: user@production.example.com

  path: /var/www/html

You can also create alias groups for running the same command against multiple environments.

For example:

wp @both core check-update

Aliases are especially useful for development, staging, and production workflows because they reduce repetitive connection and path configuration.

Use WP-CLI With Remote Servers and Containers

WP-CLI isn’t limited to traditional SSH environments. Its remote execution support includes SSH as well as Docker and Docker Compose schemes.

For example, a Docker-based environment can run a command against a container with:

wp plugin list –ssh=docker:wordpress

Docker Compose environments can similarly use:

wp plugin list –ssh=docker-compose:wordpress

WP-CLI also supports the docker-compose-run scheme for environments where the CLI container is created when the command runs.

This makes WP-CLI useful for modern local development and containerized WordPress hosting workflows as well as traditional servers.

Extend WP-CLI With Packages

WP-CLI can be extended with additional packages.

For example, packages can be installed with:

wp package install package-name

Installed packages can be viewed with:

wp package list

Packages can add commands or other functionality to WP-CLI.

Two useful examples are:

  • wp doctor — provides configurable checks for diagnosing WordPress problems.
  • wp profile — provides profiling tools for investigating WordPress execution and performance.

These are optional packages rather than commands included in the standard WP-CLI command set.

For most website owners, they are best treated as advanced troubleshooting tools rather than part of everyday WordPress management.

A Safe WP-CLI Maintenance Workflow

A practical maintenance workflow can start with:

wp core version

wp core verify-checksums

wp plugin list

wp theme list

wp core check-update

wp plugin update –all –dry-run

wp theme update –all –dry-run

Then:

  1. Confirm you are working on the correct website.
  2. Verify that a recent backup exists.
  3. Review available updates.
  4. Use dry-run options where available.
  5. Apply the required updates.
  6. Test the website after maintenance.

For production websites, avoid treating bulk updates as a completely risk-free operation. Plugin and theme compatibility should still be considered.

Security Checks Worth Knowing

WP-CLI can also help with basic WordPress security administration.

Verify Core Files

wp core verify-checksums

Verify Plugin Files

wp plugin verify-checksums –all

Revoke a User’s Sessions

wp user session destroy username –all

These commands can help identify unexpected core or plugin file changes and invalidate active sessions when account access needs to be revoked.

WP-CLI should complement, not replace, a broader WordPress security strategy.

Common WP-CLI Mistakes

Running Commands on the Wrong Website

Always verify the WordPress path, URL, or alias before executing commands.

Applying Bulk Updates Without Checking

Preview updates where possible and test important production changes.

Changing Unknown Options

Don’t modify WordPress options or configuration values simply because their names appear relevant.

Running Database Changes Without a Backup

Commands such as wp search-replace can make large database changes. Always have a reliable recovery point first.

Copying Commands Without Replacing Placeholders

Values such as plugin-name, USER_ID, and option_name are examples. Replace them with the actual values for your website.

Using Unfamiliar Commands Without Checking Their Options

Use:

wp help command-name

before running an unfamiliar operation.

Can WP-CLI Be Used in Automation?

Yes. Because WP-CLI commands can be executed from scripts and remote environments, they can be incorporated into automated maintenance and deployment workflows.

For example, teams can run commands against staging or production environments through aliases and deployment scripts.

For advanced teams, WP-CLI can also be used in CI/CD workflows such as GitHub Actions. However, automation should be designed carefully, with appropriate credentials, backups, testing, and production safeguards.

The important point is that WP-CLI can turn repetitive WordPress administration into repeatable processes rather than requiring every task to be performed manually.

Useful WP-CLI Commands at a Glance

Task

WP-CLI command

Check WP-CLI version

wp cli version

Check for WP-CLI updates

wp cli check-update

Update WP-CLI

wp cli update

Get environment information

wp –info

Check WordPress version

wp core version

Verify core files

wp core verify-checksums

Check plugins

wp plugin list

Verify plugin files

wp plugin verify-checksums –all

Preview plugin updates

wp plugin update –all –dry-run

Update plugins

wp plugin update –all

List themes

wp theme list

List users

wp user list

Revoke user sessions

wp user session destroy username –all

Flush rewrite rules

wp rewrite flush

Enable maintenance mode

wp maintenance-mode activate

Search and replace

wp search-replace old new –dry-run

List aliases

wp cli alias list

Get command help

wp help <command>

These are selected commands for common management tasks, not the complete WP-CLI command reference.

Frequently Asked Questions

Does WP-CLI work with WordPress Multisite?

Yes. WP-CLI supports WordPress Multisite and provides commands for managing network installations. The –url global parameter can be used to target a particular site within a multisite network.

Can I manage multiple WordPress websites with WP-CLI?

Yes. You can use –path, –ssh, and WP-CLI aliases to work with multiple installations. Aliases are particularly useful when you regularly switch between development, staging, and production environments.

Can WP-CLI run inside Docker?

Yes. WP-CLI supports Docker and Docker Compose through its remote execution schemes, making it suitable for containerized WordPress environments.

Can WP-CLI be used for automation?

Yes. WP-CLI commands can be used in shell scripts, deployment workflows, scheduled tasks, and CI/CD pipelines. Production automation should include appropriate access controls, backups, testing, and safeguards.

Is WP-CLI safe to use on a live WordPress website?

Yes, when used carefully. Verify the target installation, understand the command, maintain backups, preview potentially destructive changes where possible, and test the website after significant operations.

Conclusion

Managing WordPress with WP-CLI gives administrators a powerful alternative to dashboard-based management.

You can use it to update WordPress, manage plugins and themes, administer users, inspect settings, perform maintenance, verify files, work with multiple environments, and automate repetitive tasks.

Its biggest advantage is not simply that commands are faster. WP-CLI makes WordPress administration repeatable and scriptable, which becomes increasingly valuable when managing multiple websites, staging environments, or modern hosting infrastructure.

Use WP-CLI carefully: verify the target site, understand the command, maintain backups, preview changes when possible, and test production websites after maintenance.

AF
About the Author
Asher Feroze
Worked across multiple roles at CreativeON — from Manager Operations and Manager Marketing to Level 2 Client Support. Now focused on breaking down hosting and web products into simple, practical language for everyday users.
Domains
Dedicated Servers
VPS
Cloud Hosting
Google Workspace

Table of Contents