WordPress has been improved a lot during the last years, one of the best improvements has been the command line tool called WP-CLI, that allows you to do almost anything you need to manage your WordPress installation using bash commands.
Imagine we need to update all the plugins of our site at the same time:
wp plugin update --all
This command walk through all the plugins installed in your site, search a new version, download it, unzip it and update the plugin.
Before this, we need to be sure that:
- We have access to SSH to the server where the WordPress site is installed (not all the hosting providers allow this)
- WP-CLI needs to be installed and the user we use to connect be able to execute this tool.
- And that's it...
Let's start, the first step (if it's not installed) is to install WP-CLI, we just need to follow this simple steps: https://wp-cli.org/#installing
Once is installed and working, then we can do some tests, for example, install a new WordPress. We need to be sure that we have permission to create databases (in case the clean database has been created before, we can omit the
wp db create line. The other important point, the directory where we are going to install WordPress need to be a public directory on the server.
cd public wp core download --locale=es_ES wp config create --dbname=wptest --dbuser=myuser --dbpass=mypass wp db create wp core install --url=mydomain.com --title="My new WordPress Site" --admin_user=adminuser --admin_password=strongpassword --firstname.lastname@example.org
And that's it, our WordPress has been created!
Now we can find all the commands we can use here: https://developer.wordpress.org/cli/commands/