How to Downgrade Plugins, Themes, and WordPress Versions Using WP-CLI

In the fast-paced world of WordPress development, staying up-to-date is crucial. However, updates can sometimes cause compatibility issues or conflicts with existing setups. In such cases, knowing how to downgrade plugins, themes, or even the WordPress core itself can be a lifesaver. This guide will walk you through the process using WP-CLI.

Before proceeding to downgrade your plugins, themes or WordPress core versions, it’s recommended to create a full backup of your WordPress site.

Downgrading Plugins:

  1. Identify the Plugin you want to downgrade: Use WP-CLI to list all installed plugins and identify the plugin you want to downgrade. The following command will also show the current version of the plugins.

wp plugin list

  1. Check Available Plugin Versions: To see older versions of a plugin via WP-CLI you can run the following command:

wp plugin search <plugin-name> --fields=versions --format=json | jq

If the method above doesn’t provide the information you need, there are some alternative ways to check older versions:

  • Visit the WordPress Plugin Directory: https://wordpress.org/plugins/
    • Search for the specific plugin you’re downgrading
    • Most plugin pages will have a “Development” tab or a changelog section. This section often lists previous versions and their release notes, giving you a good overview of past versions.
  • You can also refer to the plugin’s official website if they have one.
  1. Downgrade the Plugin: Specify the desired version to downgrade to.

wp plugin update <plugin-name> --version=<version>

  1. Verify Installation: Ensure the plugin was successfully downgraded.

wp plugin status <plugin-name>

Downgrading Themes:

  1. Identify the Theme: List installed themes and identify the ones to downgrade.

wp theme list

  1. Check Available Themes Versions: While WP-CLI doesn’t offer an official way to view all past theme versions directly, there is an unofficial approach using WP-CLI and the jq command-line tool. This method isn’t officially documented and might not work in all WP-CLI versions. Here is an example of the command to run:

wp theme search <theme-name> --fields=versions --format=json | jq

There are also some other ways to find older versions of a specific theme if the command above does not give you enough information:

Theme Version from Developer Website:

  • If you know the version you want to downgrade to, you can skip to step 3. Otherwise, you can refer to the theme developer’s website for information on available versions.

Theme Backup (if available):

  • If you have a backup of your WordPress installation from before the theme update, you can potentially restore the backup to revert to the previous theme version. However, ensure the backup includes theme files and not just database information.
  1. Downgrade the Theme: Install the desired version of the theme.

wp theme update <theme-name> --version=<version>

  1. Verify Installation: Confirm that the theme has been downgraded.

wp theme status <theme-name>

Downgrading WordPress:

Be aware that downgrading core versions can introduce security vulnerabilities or compatibility issues.

  1. Older WordPress Versions: You can view the older versions of WordPress from the official WordPress repository (https://wordpress.org/download/releases/).
  1. Downgrade WordPress: Use WP-CLI to replace the current version with the older one. Use this command with caution and only if absolutely necessary.

wp core update --version=<version> --force

  1. Verify Downgrade: Ensure that the WordPress version has been successfully downgraded.

wp core version