Menu

Manage your Flywheel sites with WP-CLI

Updated on January 9th, 2023

One of the most useful tools available when it comes to managing WordPress sites remotely is WP-CLI. WP-CLI is a command line interface specifically designed for WordPress. It allows you to update themes and plugins, create users, create posts, and so much more all without ever visiting WP admin.

WP-CLI is available via SSH on all Flywheel sites hosted on our Flywheel Cloud Platform. For information on connecting to your sites via SSH, please read this article.



Using WP-CLI

WP-CLI is invoked by typing wp. WP-CLI includes over 40 commands, which can all be viewed here or by simply typing wp. A lot of these commands take subcommands as additional arguments, such as wp user. Typing wp user on its own will list out its available subcommands.

An example of running a command to retrieve a list of users looks like this:

$ wp user list
+----+------------+--------------+---------------------------+---------------------+------------------------------+
| ID | user_login | display_name | user_email                | user_registered     | roles                        |
+----+------------+--------------+---------------------------+---------------------+------------------------------+
| 1  | admin      | Trevan       | [email protected] | 2013-02-01 18:43:29 | administrator,backwpup_admin |
+----+------------+--------------+---------------------------+---------------------+------------------------------+

Warning

Keep in mind, many WP-CLI commands are destructive, meaning there’s no undo function. Luckily, it’s easy to create a site backup first!

Handy commands

Now that you see how to run WP-CLI commands, it’s really just a matter of finding the command you want to run to accomplish what you’re looking to do. Here are a few commands that seem to come in most handy!

List all plugins

wp plugin list

Install and activate a plugin

wp plugin install woocommerce --activate

Deactivate a plugin

wp plugin deactivate woocommerce

Reset a user’s password

wp user update [email protected] --user_pass=new-password

Change a user’s role to administrator

wp user add-cap [email protected] administrator

Check the size of database tables

wp db size --tables

Search and replace a string in the database

wp search-replace old new

Delete transients

wp transient delete --all

Generate dummy posts

wp post generate --count=10

Delete all spam comments

wp comment delete $(wp comment list --status=spam --format=ids)

Flush the WordPress cache

wp cache flush

Known commands that won’t work on Flywheel

There are a few WP-CLI commands that you won’t be able to use on Flywheel sites, primarily due to security and permissions restrictions.

  • wp config delete
  • wp config edit
  • wp config has
  • wp config set
  • wp config shuffle-salts
  • wp core update
  • wp core verify-checksums

Need help?

If you have any questions our Happiness Engineers are here to help!

Was this article helpful?

Getting Started

New to Flywheel? Start here, we've got all the information you'll need to get started and launch your first site!

View all

Account Management

Learn all about managing your Flywheel user account, Teams and integrations.

View all

Billing

Everything about billing, invoices and payments can be found here.

View all

Features

Flywheel hosting plans include a ton of great features. Learn about how to get a free SSL certificate, set up a staging site, and more!

View all

Platform Info

All the server and setting info you'll need to help you get the most out of your Flywheel hosting plan!

View all

Site Management

Tips and tricks for managing your sites on Flywheel, including going live, troubleshooting issues and migrating or cloning sites.

View all

Developer Hub

Learn how to connect, deploy, and more with SSH on Flywheel's platform.

View all

Growth Suite

Learn more about Growth Suite, our all-in-one solution for freelancers and agencies to grow more quickly and predictably.

View all

Managed Plugin Updates

Learn more about Managed Plugin Updates, and how you can keep your sites up to date, and extra safe.

View all

 

Flywheel help

Help is just a click away! Log into Flywheel dashboard to instantly chat with an expert, respond to a ticket, or follow along with in-depth documentation. We happily offer support 24 hours a day, 7 days a week, 365 days a year!

Log in

Try Flywheel today

Launch your next WordPress site in minutes.

 Free migrations  24/7/365 support  14 day demo sites