Today I Learned, Wordpress

WordPress has a CLI

So it turns out WordPress has a CLI! I’m not sure how this had passed me by but I’m really pleased I’ve found it. WordPress installation is famously easy but automation is always a good thing. Installation is really straightforward so I won’t repeat the instructions here. Here are some of the commands which caught my eye:

Installing a New WordPress Site

These commands will install the latest version of wordpress in the current directory.

# Download the Latest Version
wp core download --locale=en_GB

# Set the config values for the database
wp config create 

# Install
wp core install 
   [email protected]

Installing Plugins

First you need to find the plugin. You can do that using the search.

wp plugin search <search_term>

So to search for the word “classic” I ran:

wp plugin search classic
Success: Showing 3 of 955 plugins.
| name              | slug               | rating |
| Classic Editor    | classic-editor     | 100    |
| TinyMCE Advanced  | tinymce-advanced   | 92     |
| Disable Gutenberg | disable-gutenberg  | 100    |

Then to install one (and activate) just use the slug given in the search results:

wp plugin install classic-editor --activate

User Management

You can create new users. If no password is specified then one is generated for you.

wp user create bob [email protected] --role=editor
Success: Created user 2.
Password: 2DCGMaYzA3f3^#%o&X(sJNR8

If you add –send-email it will send the user an email containing their username and password.


I’m so pleased I found this tool. By combining this will other cli tools I can orchestrate server creation, database creation and now wordpress site installation. Expect more write-ups soon!