# WP-CLI command reference

WP-CLI is the command-line interface (CLI) for WordPress. It is installed on every TurboStack host as `wp`, so you can manage a site over SSH instead of clicking through the admin. This makes it fast for updates, bulk changes and scripting across many sites. This page groups the common commands by task. For where the files live and the cron setup, see [WordPress reference](reference.md).

## How to run it

Connect over [SSH](../../platform/hosts/ssh.md), change into the WordPress root, then run `wp`:

```bash
cd ~/public_html
wp <command>
```

Here `~` is your system user's home directory (for example `/var/www/prod/`), and `~/public_html` is the WordPress root. WP-CLI reads `wp-config.php` from this directory, so always run it from there (or pass `--path=/var/www/prod/public_html`).

Run `wp help` for the full command list, or `wp help <command>` for the options and examples of a single command.

## Core

| Command | What it does |
| --- | --- |
| `wp core download` | Downloads WordPress core files. |
| `wp core install` | Runs the WordPress installation. |
| `wp core update` | Updates WordPress core to the latest version. |
| `wp core version` | Displays the current WordPress version. |
| `wp core check-update` | Checks for available core updates. |

## Plugins

| Command | What it does |
| --- | --- |
| `wp plugin install <plugin>` | Installs a plugin by slug or URL. |
| `wp plugin activate <plugin>` / `deactivate <plugin>` | Activates or deactivates a plugin. |
| `wp plugin update <plugin>` | Updates a specific plugin. |
| `wp plugin delete <plugin>` | Deletes a plugin. |
| `wp plugin list` | Lists installed plugins with status. |

## Themes

| Command | What it does |
| --- | --- |
| `wp theme install <theme>` | Installs a theme by slug or URL. |
| `wp theme activate <theme>` | Activates a theme. |
| `wp theme update <theme>` | Updates a specific theme. |
| `wp theme delete <theme>` | Deletes a theme. |
| `wp theme list` | Lists installed themes. |

## Users

| Command | What it does |
| --- | --- |
| `wp user create <username> <email>` | Creates a new user. |
| `wp user list` | Lists all users. |
| `wp user update <user>` | Updates user information. |
| `wp user get <user>` | Displays user data. |
| `wp user delete <user>` | Deletes a user. |

## Database

| Command | What it does |
| --- | --- |
| `wp db export` | Exports the database to an SQL file. |
| `wp db import <file>` | Imports an SQL file into the database. |
| `wp db check` | Checks database for errors. |
| `wp db optimize` | Optimizes the database. |
| `wp db reset` | Drops all tables and reinitializes the DB. |

## Content and options

| Command | What it does |
| --- | --- |
| `wp post create` / `update <id>` / `delete <id>` / `list` | Creates, updates, deletes, or lists posts. |
| `wp media import <file>` | Imports media files into the Media Library. |
| `wp media regenerate` | Regenerates image sizes for Media Library. |
| `wp option get <name>` / `update <name> <value>` / `delete <name>` | Gets, updates, or deletes an option value. |
| `wp config create` / `set <key> <value>` / `get <key>` | Creates a `wp-config.php` file, or sets and gets config values. |

## Cron

| Command | What it does |
| --- | --- |
| `wp cron event list` | Lists scheduled cron events. |
| `wp cron event run <hook>` | Executes a cron event immediately. |
| `wp cron event run --due-now` | Run all events that are due |
| `wp cron event delete <hook>` | Deletes a cron event. |

For reliable scheduling, replace the default web-triggered `wp-cron` with a real cron job that calls WP-CLI - see [WordPress reference](reference.md#cron).

## Cache and search-replace

| Command | What it does |
| --- | --- |
| `wp cache flush` | Clears the object cache. |
| `wp transient get <name>` / `set` / `delete` | Gets, sets, or deletes a transient value. |
| `wp search-replace <old> <new>` | Replaces strings in DB. |
| `wp rewrite flush` | Flushes rewrite rules. |

> [!WARNING]
> Always test `wp search-replace` with `--dry-run` first. It reports how many rows would change without writing anything. This matters most when moving a site between domains (for example `dev.example.com` to `example.com`).

> [!NOTE]
> `wp cache flush` clears WordPress's own object cache. The platform caches (Redis and Varnish) are separate - clear those with the TurboStack command-line tool (`tscli redis clear`, `tscli varnish clear`). See [TurboStack CLI](../../api/cli.md).

## WP-CLI itself

| Command | What it does |
| --- | --- |
| `wp cli update` | Updates WP-CLI itself to the latest release. |

## Related

- [WordPress reference](reference.md)
- [Deploy WordPress on TurboStack](deploy.md)
- [WordPress best practices](best-practices.md)
- [Troubleshooting WordPress](troubleshooting.md)
- [Connect over SSH](../../platform/hosts/ssh.md)
