The Power of WP-CLI

Dipping into WP-CLI

Last updated: 01-Feb-2020

In the latter months of 2019, I began to explore more earnestly the command line tool for WordPress, WP-CLI. I quickly discovered that for someone who prefers the keyboard to the mouse, it’s a wonderfully powerful, quick, and robust tool for managing and updating WordPress sites.

A Lightning Talk at the Philly ‘burbs WordPress Meetup

View Dipping into wp-cli on Notist.

In early December, I shared a few quick items that I’d already learned about WP-CLI. I gave a lightning talk at the Philly ‘burbs WordPress Meetup’s 12 Tips of WordPress. The slides embedded above are from that little talk.

What follows below is a resource that I’ve building up for myself. When and where I find documentation and links that I use for growing my knowledge about how to harness the power of WP-CLI, I post them here. Feel free to bookmark this page in your own browser if find it of value.

Commands and Resources for WordPress Generally

https://developer.wordpress.org/cli/commands/

Commands for Gravity Forms

My Own Personal Favorites for WP-CLI

Duplicate a page or post from existing page or post

wp post create --from-post=136 --post_type=page --post_parent=41  --post_title="Insert New Page Title Here"

Delete a User

# Delete user 123 and reassign posts to user 567
$ wp user delete 123 --reassign=567
Success: Removed user 123 from http://example.com

Search/Replace

This is very useful when upping a database after installing an SSL certificate or updating A-records on a new website.

wp search-replace 'http://example.com' 'http://example.test' --recurse-objects --skip-columns=guid --skip-tables=wp_users