Manage your WordPress via CLI

Manage your WordPress via CLI

en flag
tr flag
Voiced by Amazon Polly

Managing your WordPress on a OS without a GUI can be a bit complex, you should use several command to make changes like install plug-ins, modify setting etc. For instance, when I was trying some settings, WordPress stopped to work suddenly and I lost access to WordPress admin panel. Then I realize that I had to deactivate a plug-in but I didn’t know how can I do this with command line. I made some research on Google and I’ve found a tool that allows you easily manage your WordPress via command line; wp-cli.

I will not explain how to setup and configure it in this post, because there is already a good and simple documentation on wp-cli website. On the other hand, I want to give some examples about usage of wp-cli to show you how easy to use it.

Here is some useful commands as example;

To install a plug-in; $ wp plugin install <plug-in name>
To deactivate a plug-in; $ wp plugin deactivate <plug-in name>
To list installed plug-ins; $ wp plugin list
To delete a post; $ wp post delete <post id>
To create a admin user; $ wp user create <user-name> <user-email> [–role=’administrator’] [–user_pass=<user-password>]
To activate a theme; $ wp theme activate <theme name>
To list installed themes; $ wp theme list

Of course, there are too many other useful commands and parameters which I can’t list all of them. You can see all of these with $ wp help command.

Tip: When you are logged in with root user, you will get an error message about it. If you prefer continue with root user, you should add –allow-root flag at the end of the commands.

Leave a Reply

Your email address will not be published. Required fields are marked *