brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp plugin install --version --force rolls a WordPress plugin back

WordPress
~/tips/tip-wordpress-plugin-install-version-rollback

wp plugin install my-plugin --version=2.4.1 --force

Puts an older version of a WordPress plugin back after an update breaks something.

A plugin update that breaks your site always arrives at a bad moment, and the WordPress admin has no button to go back a version. WP-CLI does, it’s just hidden in the install command.

wp plugin install takes a --version flag that fetches that exact version from wordpress.org instead of the latest stable one. Add --force and it overwrites the version that’s installed now without asking:

wp plugin install my-plugin --version=2.4.1 --force

That puts you back on the release that worked. Which version that was is easy to find if you updated with WP-CLI: the table that wp plugin update prints has an old_version column.

It works the other way round too. wp plugin update my-plugin --version=2.5.0 moves to one specific newer release, which is my choice when the newest version is fresh and I’d rather take the one before it.

The caveat that matters: going back in code doesn’t take the database back. If the new version changed tables or options when it ran, the old code now meets data it doesn’t know, and that can break in new ways. That’s why I’d always pair this with a database dump made before the update. Two smaller things. It only works for plugins from wordpress.org; a premium plugin from a zip needs that old zip. And if auto-updates are on for the plugin, WordPress will happily install the broken version again at the next run, so switch them off for that plugin until a fixed release is out.

Further reading: wp plugin install (WP-CLI commands), wp plugin update (WP-CLI commands)

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link