WP-CLI makes it very easy to rollback plugins and themes as well as update plugins and themes on sites all from command line. This is useful if you see your site is broken by a newer version of the theme or plugin. In this article, we’ll be running through some valuable commands for rolling back your site.
If you need to rollback a plugin on a site to a previous version, you can find the previous version number from the development tab of the plugins listed on WordPress.org. To find the slug of the plugin, you will need to go to the WordPress.org plugins. In the case of Contact Form 7, the plugin slug is contact-form-7.
Rollback a Plugin to a Previous Version
If you need to test that the command is correct, you can always use the flag –dry-run at the end of the command:
In the following example, to rollback Contact Form 7, you can use this command:
Activate A Particular Version of a Plugin
If you need to install and activate a previous version of a plugin, run:
Update All Plugins
If the plugins you updated have been fixed and you now need to update all plugins, the example command is:
Excluding A Plugin
If you want to update all plugins, but need to exclude a specific plugin (in this case WooCommerce), run command:
Rollback a Theme to a Previous Version
Update Theme to Current Version Release
If you know wanted to update the Storefront theme on a site to the most current version, you could use this command example;
Using a mix of these WP-CLI commands will enable you to easily rollback a plugin on your site, rollback a theme, or update all plugins. It will also update all plugins, but exclude a specific plugin from being updated. Our Managed WordPress product comes with WP-CLI installed along with easy, automatic updates. Check out how our Managed WordPress platform can streamline your work today!