Skip to Content

WP-CLI: Manage WordPress from the Terminal

Faster than clicking through admin

WP-CLI is the most underrated tool in the WordPress ecosystem. Everything you can do in admin, you can do faster via the command line. And some things you can do that aren't even possible through admin.

Installation

One line: curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar. Make it executable, move to /usr/local/bin/wp. Works on Linux and macOS. Windows users need WSL.

Everyday commands

wp core update updates WordPress. wp plugin update --all updates all plugins. wp db export backup.sql takes a database backup. Three commands that replace ten minutes of clicking.

wp plugin list --status=inactive shows inactive plugins. wp plugin delete removes them. Clean up the site in 30 seconds.

Search-replace

Perhaps the most important feature. wp search-replace 'http://old-url.com' 'https://new-url.com' --all-tables replaces all occurrences in the database. Essential for migrations, domain changes, or switching to HTTPS. Try doing it manually in phpMyAdmin with serialized data. (Don't.)

Batch operations

Change author on all posts: wp post list --post_type=post --format=ids | xargs -I {} wp post update {} --post_author=2. With 500 posts that would take half a day through admin. With WP-CLI it takes seconds.

If you manage more than one WordPress site, WP-CLI is worth learning. Invest an afternoon, save hours every month.

Advanced Custom Fields: How to Use ACF in Client Projects
From blog engine to full-featured CMS