Unlike the WordPress content editor that has undo and redo buttons, the WordPress “theme editor” does not. The only way to undo changes in a WordPress theme is to use a method to roll it back.
Only two methods work. Restoring from a backup, or rolling back a plugin to a previous version. Because plugins make changes to your theme.
Both can be done manually or backups can be automated.
Read on to discover the steps that should be taken to make certain that any changes done to a WP theme can be undone. Just in case.
How to undo changes in a WordPress theme
Changes to WP themes can be undone by uploading backup files to the server. Alternatively, keep a copy of the source code to paste back. If an edit breaks your theme, all changes are undone by reinstalling the theme. The WP Rollback plugin can undo changes plugins make to WP theme files.
Using a plain text editor
Use this before editing as it is a faster way that avoids downloading, editing, and uploading backup files. Copy and paste everything into a plain text editor before you make the changes.
This way, if your edits do not take, you will have a swipe file at the ready to paste right back in.
Whatever bad code that was put in can be replaced with the original source code.
If you are already past that stage, there is still hope…
Restore only the file template that had changes added
Download your original WordPress theme, open the folder and navigate to the template file that has been edited. That is your original source code.
The benefit to using the original theme coding is that you can copy and paste only the section that has been edited on a single template file. It retains all other changes done to different file templates.
Find your original WP theme, download the zipped file to your desktop, then open it to find the file template you want to undo changes on.
Copy and paste all of the code into the file you edited and that restores all of the original source code.
If you only want to undo changes to a section of a file template, find the code that was changed, and paste back just the original snippet.
Undo changes with cPanel manually
When your WordPress site has no backups happening, taking precautions before editing theme files is essential. And it is easy.
To use an example, suppose you wanted to add a left sidebar into your WP theme. This would require editing the functions.php file.
Do something wrong when there are no backups as a safety net, the only way to restore the function is to use the method described above.
Any previous edits that did work will be removed with that method though. You can get backups from cPanel for any theme file template.
This way, if your edit does stop something working on your site, you can go back, delete the file template from the theme folder, then upload the original file to restore a function that a theme edit broke.
Reinstall the theme
This is probably going to be the last of your preferences if you have done a lot of theme customizations.
The reason is that reinstalling the theme from scratch, deletes your previous edits. On every template file.
Still, if you have made changes to your WordPress theme files that have totally broken your website, you can quickly get it back up and running, then you can see to customizing things – again.
To reinstall your current theme, you need to delete the entire theme folder from your server.
- Login to cPanel,
- open File Manager,
- navigate to your WP Content folder,
- open the Themes folder,
- right-click on the theme that is not working as it should,
- then click delete.
Once done, go back to your WP dashboard, go to Appearance > Themes > then click Add New. Search for the theme you deleted, or upload an older version.
The majority of premium themes will provide a download link. Check your email, or log in to your online account where you purchased the theme.
If you are using a custom theme, upload your original zipped theme folder.
Undo plugin updates that break your WP theme
Plugins on WordPress inject coding into your theme to extend its functionality. If an update rolls out that does not play well with your theme, things break.
When you need to undo changes in a WordPress theme that has been caused by a plugin, the WP Rollback plugin could be a saving grace.
This works using the WordPress.org repository. As such, if your plugin is not listed in the repository, it will not be able to find a restore point.
On your plugins page, this shows a rollback option for every plugin you have installed, but only when it can be rolled back.
If it cannot be rolled back, the “rollback” link is not shown. No harm, no foul. You may as well see if it works for your site.
Go to plugins > add new, search for WP Rollback by Impress.org.
Install and activate the plugin. Now, all of your plugins will show a “rollback” link when it is available.
The plugin connects to the “developer logs” on WordPress.org to pull in older plugin versions. That is why it will not work with third-party plugins not listed within the repository.
How to undo changes in WordPress theme caused by a third-party plugin
For unlisted plugins, which are usually those you buy from a website to upload manually, the WP Rollback will not work. You need to do that manually.
To get older versions of a plugin, go to the developers’ website to see if there is a version history available.
If not, contact them to ask for a copy of an earlier version.
For plugins you have had custom developed or built yourself, check your computer for the original compressed folder.
The only way to roll back custom plugins is to delete the broken version then upload the original. The same as you would do to reinstall a theme.
Backup and Restore options to undo changes in a WordPress theme
All methods to undo changes in a WordPress theme revolve around downloading original file templates before editing, then uploading the backups to restore previous versions.
The fastest way to restore changes from backup files is to use backup plugins or services (often provided by web hosts).
If your host does not provide backups, add a plugin to automate the process.
Do this before making future edits to your theme template files. Otherwise, there will be no restore points to use.
There is no shortage of backup plugins or third-party services. Popular backup plugins for WordPress are Backup Buddy and Updraft Plus.
As an example using Updraft Plus, you can set it to back up everything and have it sync with cloud storage.
To restore from a backup, go to the Updraft Plus settings page, view existing backups, pick a restore point by the most recent date, then press themes, and then restore.
This will undo recent changes to your WordPress theme.
Set up frequent backups for your WP website. Without them, the only way to undo changes in a WordPress theme is to undo every customization ever done. Over time, that can be a lot of work undone.
Hey guys! It’s me, Marcel, aka Maschi. On MaschiTuts, it’s all about tutorials! No matter the topic of the article, the goal always remains the same: Providing you guys with the most in-depth and helpful tutorials!