WordPress wizard – wp-cli

Managing WordPress is pretty easy. The easy install process in most cases through “one click installs” let us run WordPress in no time.
Installing plugins if you know which you need ideally have them marked as favorites on the WordPress.org makes it even easier.

But what about content, I mean some content you can work with as website developer. We cannot style up something that does not exist right :) ?
Make one post after the other – the user friendly way is not really developer friendly way. What if we can just generate posts or change the user password and don’t want to bother with PHPAdmin, regenerate countless images and so on and so forth? ..How?

The command line way .. whooAaaa comand line what? Are you crazy?
If you think I’m crazy just skip this post.. if you are still interested keep reading.

Wp-cli is a PHP command line tool that is made just for us WordPress developers. People who want to do same thing often and wanna stay DRY.

The wp-cli installation is easy, though you have to have the SSH access or work on your own local machine where you have all the necessary rights. If your hosting does not give you SSH access then believe me or not you have chosen bad hosting. One of the easiest way to work with is to have you hosting on Dreamhost which has the wp-cli pre-installed and ready for all their users and offers the SSH access for ages already. Or if you happen to be in Czech republic you might consider this convinient hosting on Mixhosting with SSH access but this time you have to install the wp-cli your self, anyway :)

Hands on

Simple install (as not sudo user):
Log in to your server via SSH. Install via git

git clone git://github.com/wp-cli/wp-cli.git ~/git/wp-cli
cd ~/git/wp-cli
./utils/local-build

Then go to your WordPress home directory, for example:

cd example.com

and check if it works. Type:

wp

if it works, it’ll print out some basic howto.

Examples

Website migration..so you  migrated the website form local to a live server, but forgot to change the site url to the live destination.. what now?

check the actual option

wp option get siteurl

change it to your needs

wp option update siteurl http://liveserver.com

(if you wanna be complete do the same for home option ;) “wp option get home”) 

What about the user password

list users (we need the user ID)

wp user list

change the admin password

wp user update 1 --user_pass=1234

Sweeeeeet :)

Populate WP with some posts

wp post generate --count=4

Regenerate all images according to registered sizes:

wp media regenerate

Can it be easier?

If you need any help just type wp –help
Or go to http://wp-cli.org/ it’s packed with tons of useful command and features.