All of us who in one way or another are linked to web development and use WordPress know of HelpWordpress.com. Without a doubt one of the main sites linked to this CMS.
Just before yesterday I read an extremely interesting article that deals with the same thing, controlling or managing a site in WordPress using nothing more and nothing less than our terminal 😉
I asked the author of it for permission to share it here, thanks a lot to Fernando for such a great article and for letting us share it with you 🙂
Well, here is the post:
Well notice that this WordPress command line is geek, but very geekNothing for all audiences but in any case one more possibility of the ecosystem that WordPress has become.
La command interface for WordPress: wp-cli, is a series of commands to manage WordPress installations and more. And is that with wp-cli you can update plugins, install WordPress, publish posts, practically everything and growing.
Oh and It is not a plugin, it is a system that requires its own installation that you can do in various ways, namely ...
Through pear you would do it like this:
sudo pear channel-discover wp-cli.org/pear
sudo pear install wpcli/wpcli
git clone --recursive git://github.com/wp-cli/wp-cli.git ~/git/wp-cli
cd ~/git/wp-cli
sudo utils/dev-build
Where can you replace ~/git/wp-cli
with what you want.
And in MAMP, XAMP, etc.
If there is no php command available you can try to find a binary to do it from:
./utils/find-php
Then you create an environment variable called WP_CLI_PHP
with the route you find find.php
In an environment UNIX you could do it by adding the following line to your file .bashrc:
WP_CLI_PHP=/path/to/php-binary
Ok, very good, I already have it installed but ... How is this used?
Well, you go to the root folder of WordPress:
cd /var/www/wp/
If you type wp
you should see output similar to this:
Available commands:
wp blog create | delete
wp cache add | decr | delete | flush | get | incr | replace | set | type
wp comment create | delete | trash | untrash | spam | unspam | approve | unapprove | count | status | last
wp core download | config | is-installed | install | install-network | version | update | update-db
wp db create | drop | reset | optimize | repair | connect | cli | query | export | import
wp eval-file
...
See 'wp help' for more information on a specific command.
From there we can, for example, install a plugin from WordPress.org. In order not to complicate the example, we chose the useless Hello Dolly:
wp plugin install hello-dolly
Y lo que veremos será esto:
Installing Hello Dolly (1.5)
Downloading install package from http://downloads.WordPress.org/plugin/hello-dolly.1.5.zip…
Unpacking the package ...
Installing the plugin…
Plugin installed successfully.
As you can see, the commands, once installed, are really simple and intuitive.
Another example would be a Multisite installation, where we would have to give wp-cli the parameter --blog
So you know which website you are supposed to act on:
wp theme status --blog=localhost/wp/test
Y si es en una instalación en subdominio sería algo así:
wp theme status --blog=test.example.com
If you are working on the same site most of the time you can put the url of that site in a file called 'wp-cli-blog
'that you will create in the root folder of your WordPress:
echo 'test.example.com' > wp-cli-blog
From this moment you can call wp
without the parameter --blog
:
wp theme status
The complete list of commands is here, and you can even create more commands in wp-cli's kitchen.
Well, as I warned you, it is not something for anyone to use daily, but it is a great way to manage a WordPress from the command line, for example through SSH, so save the link there for when you have a few silly days in those who do not know what to mess with WordPress.
And so the post ends.
Fernando said at first that it was a post for geeks ... but, almost all of us don't see this really great? 😀… LOL !!, I don't know about you but the idea of being able to control WordPress with commands I find it really phenomenal ♥ 0 ♥
Many thanks to Fernando for the post once again, this article was originally taken from HelpWordpress.com.
I hope you have found it interesting 😉
regards
Just great!
I'm going to put it into practice right now. You just gave me a joy.
Thank you so much for sharing, KZKG ^ Gaara.
Greetings!
Nothing, a complete pleasure to help 🙂
regards
Nice Job… .. now I finish «dominating» my Nginx I'll see if that wp-cli thing works…. and if someone wants to call me a geek because I like the console variants it doesn't bother me at all xD
See if I can give myself time to finish driving Drush.