WP-CLI, a neat tool for managing your WordPress websites
As I’ve stated many times before, I like to break things. While migrating a dozen or so WordPress websites from my old web server to a high-availability network of web servers I seem to be breaking them left and right! Luckily WP-CLI was here to save the day!
I’ve yet to figure out the exact cause of an issue causing infinite redirects. I’m using the same nginx configurations and just moving the files to a new location. Regardless, I’ve been locked out of wp-admin just about every time. Some of the common issues I have dealt with are having to change file paths in the configuration for WP Super Cache and in one case a website was set to flexible SSL on Cloudflare. Flexible SSL broke the website in question because HTTPS is forced on the HAProxy sitting in front of my web servers.
Luckily for those times where I was locked out I was able to write and install a plugin to fix redirect issues with WP-CLi. The plugin was just a nice drop-in that I called stop-redirect, it does what its name entails and stops WordPress from trying to redirect visitors on the home page. Fortunately even though I could not access wp-admin I was able to use WP-CLi to enable my plugin by simply entering the directory of the WordPress install and typing
wp plugin activate stop-redirect.
This awesome tool doesn’t just stop at managing plugins though. You can fully manage your WordPress website with WP-CLI, doing everything from managing users to managing posts, and even managing the menu items and widgets that appear on your website! Needless to say, I don’t know what I would have done had I not had this tool handy to patch things up and get my sites working again. Hopefully by sharing my experience you, or someone else, will also find this tool helpful.