Couchbase – USE KEYS for performance gains
December 17, 2019Multifactor Authentication and Its Benefits
January 23, 2020With all the WordPress installs on the web, it’s inevitable that you will need to shorten the maintenance time for each install. If you have multiple sites on a server, the WordPress CLI will be an invaluable addition to your workflow. We’ve added it to ours and I’m going to show you how to use it for your full site maintenance plan.
The safest way to update WordPress is to start with the core and do the plugins and themes thereafter. This will give the plugins and themes the newest WordPress version to update. If you don’t update core before them you might get an old plugin or theme version. So to start out use the wp core command.
wp core update --quiet
Adding –quiet to the command will quiet any responses from the script. For us, this comes in handy because we have created a script for all of these commands to run at once. More on that later.
wp core update-db --quiet
There are times when updating the WordPress that a database update needs to be run. If you don’t run this command, a page will show after your first login to the admin to update the database manually.
Next, I like to update the themes that are currently installed. There is a caveat to updating themes in WordPress this way. The best way to update a theme is to have a child theme of it so you don’t lose any of your custom changes during the update. But also, when a theme has been uploaded to the site from a .zip file on your computer this update will not work. This, in most cases, is when you get a theme from a marketplace site and it’s not downloaded directly from the site. Here is how to update the theme:
wp theme update --all --quiet
After the themes comes the plugins, the meat and potatoes of the WordPress diet. This command is, of course, similar to the others.
wp plugin update --all --quiet
For us we have a plugin that can’t be updated to a newer version because it breaks the custom slideshow we have created. The WordPress CLI has a solution for this, we can exclude a certain plugin while we update all the others. If we add ‘ –exclude=slider-plugin’ before –quiet it will exclude that certain plugin:
wp plugin update --all --exclude=slider-plugin --quiet
And that’s it. Those three simple commands will update your WordPress fully. As mentioned earlier, we created a script for all of this to be run at once. It has really brought down maintenance time for us on all of our sites. As developers it’s always on ours minds to automate the monotonous things that we need to do more than once. And here is just another way to do that.