Fun with WP CLI

Add yourself as an admin user
wp user create myusername --role=administrator --user_pass='password'

Quickly reset a list of user passwords
wp user list
wp user update user1 user2 --user_pass='password'

Correct URLs after DB migration
wp option update siteurl ''
wp option update home ''
wp search-replace '' ''

Generate MySQL prompt
wp db cli

Regenerate thumbs
wp media regenerate

Convert to subdomain multisite install
wp core multisite-convert --title='My Network' --subdomains

Update the title for page with slug ‘about’
wp post list --pagename=about
wp post update <post ID> --post_title='New Title'

Update ‘Mood: Happy’ to ‘Mood: Sad’ for the same page, without knowing the name of the field
wp post meta list <post ID>
wp post meta update <post ID> my_mood 'Sad'

Remove unneeded themes
wp theme list
wp theme delete themename1 themename2

Toggle state of plugins ( active / inactive )
wp plugin toggle plugin1 plugin2

Create new empty child theme
wp scaffold child-theme <slug> --parent_theme=<slug> [--theme_name=<title>] [--author=<full-name>] [--author_uri=<uri>] [--theme_uri=<uri>] [--activate]

wp scaffold child-theme my-child --parent_theme=genesis --theme_name='My Child' --author='Pat Ramsey' --author_uri= --theme_uri= --activate


  1. Thanks Pat.

    Question for you: I’m looking to use a script someone wrote to run multisite upgrades (

    In the CLI Wiki / Commands Cookbook under Loading it says that one way to use a 3rd party CLI command is to run

    wp –require=my-command.php my-command

    I tried that, as

    wp –require=/path/to/multisite-network-upgrade.php multisite-network-upgrade

    and got

    Error: This does not seem to be a WordPress install.

    What am I missing here?

  2. Never mind – I figured it out.

    Answering my own question: you need to cd into the target directory first, then can run the above and it does the upgrade.


    cd /path/to/WPsiteDirectory
    wp –require=/path/to/multisite-network-upgrade.php multisite-network-upgrade

    results in :

    Success: upgraded
    Success: upgraded
    Success: upgraded

%d bloggers like this: