It usually goes like this. You paste a snippet into functions.php, hit Update File, refresh the site and… nothing. A blank page. Or the layout collapses. Or WordPress greets you with a critical error message and won’t even load the dashboard.
The Theme File Editor is one of the most useful tools in WordPress, and one of the least forgiving. Every save writes straight to the live file on your server. There’s no undo button, no version history, no “are you sure?” popup. One missing bracket and your afternoon is gone.
The good news: almost every theme editor mistake is fixable, and most are fixable in minutes. In this guide I’ll walk you through how to undo theme editor changes in WordPress, starting with the method that works for most people (a backup), then moving to fixes for when the dashboard itself has died, and finishing with habits that keep this from happening again.
Pick the section that matches your situation. If your dashboard still loads, you have more options. If it doesn’t, skip straight to the file manager or FTP methods.
First, Know What You’re Working With
The Theme File Editor is WordPress’s built-in code editor. Site admins can open it from the dashboard and edit the raw files of the active theme.
You’ll find it here:
Dashboard → Appearance → Theme File Editor
Depending on your WordPress version, the menu item may just say Theme Editor. Some hosts hide it entirely for security reasons; if you’ve never seen it, that may be why.
What can you actually edit in there? In a typical theme:
- style.css: the stylesheet. Fonts, colors, spacing, breakpoints, all of it.
- functions.php: where a theme registers its features, and where everyone pastes custom PHP snippets.
- header.php and footer.php: the markup that wraps every page.
- single.php: the template that displays individual blog posts in most classic themes.
- page.php: the template used for standard pages in most classic themes.
Here’s the part that trips people up. When you click Update File, WordPress overwrites the file on the server immediately. The editor doesn’t keep a rolling history of saved versions you can flip back through. So “undo” really means one of two things: restore an earlier copy of the file from somewhere, or manually reverse the edit you made.
That’s the mental model for this entire guide. Everything below is a variation on those two moves.
Why Theme Editor Changes Need Undoing in the First Place
Five situations come up again and again.
Slipped keys. You meant to add a line and deleted one instead, or dropped a bracket, or pasted a snippet twice. PHP shows no mercy; one stray character in the wrong place stops the whole file from running.
CSS that didn’t do what you expected. A change to style.css can wreck font sizes, colors, margins, or the mobile layout. The site still works, it just looks wrong. Restoring the previous CSS usually sorts it out.
The fatal error. Bad PHP in functions.php or any template file can crash the site. WordPress 5.2 and later shows a critical error screen and, if you’re lucky, emails the admin a recovery link. In the worst case the dashboard is unreachable too, which rules out fixing things from the editor itself.
Conflicts. Custom code that plays nicely today can collide with a plugin update or a WordPress core update tomorrow. Rolling the change back is how you confirm the edit was the culprit.
Regret. Sometimes the code works perfectly. You just don’t like what it did. That’s a perfectly valid reason to revert.
Before you touch anything, answer two questions. Can you still open the dashboard? And do you have a backup from before the edit? Those two answers decide which method below is fastest for you.
If You Have a Backup: Restore It
Best for: getting back a known-good file, or undoing several changes at once.
A backup is the cleanest fix there is. You’re not repairing anything; you’re time traveling. Your copy might live with your host, inside a backup plugin, on a staging site, or in a folder on your own computer.
Step 1. Log in to WordPress. Head to https://yourwebsite.com/wp-admin and sign in.
Step 2. Find your backups. Check your hosting control panel for a backup or restore-point feature. Common plugin-based options include UpdraftPlus, Duplicator, and Jetpack VaultPress Backup. Or maybe you downloaded a manual copy of the site at some point. What you can restore depends entirely on your hosting plan and backup setup.
Step 3. Work out which file to restore. Think back to what you edited:
- Colors or spacing went wrong? That was probably style.css.
- White screen after a PHP snippet? functions.php.
- Header vanished? Look at the header template or whatever you customized.
- A specific page template broke? Restore that template.
Step 4. Restore it. If your backup tool supports single-file restores, restore just that file. If it only does full-site restores, stop and read the restore points carefully before you continue.
A word of caution, because this is where people cause real damage: restoring an entire site from an older backup also rolls back posts, pages, orders, customer records, anything created after that backup was taken. Whenever you can, restore the single file. If you can’t, test the restore on a staging copy first.
Step 5. Clear every cache. Caching plugin, server-side cache, CDN cache, all of it. Then open the site in a private browsing window and confirm the old design or behavior is back.
Why this works: a backup is simply an earlier copy of your files. Restore the right one and the unwanted edit disappears, no code archaeology required.
If the Dashboard Is Dead: Use Your Host’s File Manager
Best for: recovering a site when a PHP error has locked you out of wp-admin.
A fatal error means no dashboard, but your files are still sitting on the server, and your hosting account gives you a way to reach them.
Step 1. Log in to your hosting account. You’re looking for a File Manager. On cPanel hosts it’s an icon on the main screen; other hosts use their own dashboard or a file browser.
Step 2. Find your WordPress folder. Usually that’s public_html. If WordPress lives in a subdirectory or a different document root, open that instead.
Step 3. Open the theme folder. The path looks like this:
wp-content/themes/your-active-theme/
Swap in your theme’s real folder name. If your theme is called mytheme, you end up at wp-content/themes/mytheme/.
Step 4. Find the file you edited. Say the damage came from a snippet in functions.php. You’re looking at wp-content/themes/mytheme/functions.php. If you edited a different file, find that one.
Step 5. Save a copy of the current file first. Download it, or duplicate it in the file manager. This sounds paranoid right up until the first time a “quick fix” makes things worse and you want the previous state back. If you have a clean backup of the original, compare the two versions and see exactly what changed.
Step 6. Put the original code back. If you have a clean copy of the file, upload it over the broken one. If you don’t, delete only the specific lines you added, and only the ones you’re sure about. Be gentle with functions.php: remove the wrong block and you might take out something the theme needs to run.
Step 7. Save and test. Reload the homepage, a blog post, a key landing page, and the dashboard. Still erroring? Check the error logs in your hosting panel, or open a ticket with your host. They handle this exact problem constantly, and it’s a good use of support.
One don’t: never paste in a random copy of a theme file downloaded from some forum. Theme files differ between versions, and a mismatched replacement just trades one problem for two.
Same Job, Different Tool: FTP or SFTP
Best for: site owners who’d rather browse files from a desktop app than click through a hosting panel.
FTP and SFTP do the same work as the file manager, just through a dedicated client. FileZilla is the usual choice. SFTP is the better option when your host supports it, because the connection is encrypted.
Step 1. Get your credentials. Your hosting panel lists FTP/SFTP accounts somewhere. You need the server address, username, password or SSH key, and port. Use the connection details your host supplies, and keep them private; they’re the keys to your site.
Step 2. Connect. Enter the details in your client, connect, and open the folder where WordPress is installed.
Step 3. Go to the theme directory.
wp-content/themes/your-active-theme/
Find the file you edited through the dashboard.
Step 4. Download the broken version first. Keep a local copy of what’s on the server right now. If your repair goes sideways, you’ll want the “before” state.
Step 5. Upload your clean copy. If you have the original file from a backup, drop it into the theme folder and let it overwrite. Double-check the filename and path; good code in the wrong place helps nobody.
Step 6. Check the site. Front page, a post, desktop view, mobile view. Clear the cache if the change doesn’t show up.
FTP earns its keep precisely when the dashboard is dead. It’s also the easiest way to grab quick backups of theme files before you edit them, which you should be doing anyway.
Small Mistake, Dashboard Still Working? Reverse It Manually
Best for: minor edits when you know exactly what changed and the site still runs.
If nothing crashed, the fastest fix is often to undo your own edit in the same editor.
Step 1. Open the editor at Dashboard → Appearance → Theme File Editor. Pick the active theme if WordPress asks.
Step 2. Open the file you touched. CSS change? style.css. Snippet? functions.php.
Step 3. Compare against your original. If you copied the file’s contents somewhere before editing (please tell me you did), diff it against the current version and spot the lines that changed.
Step 4. Reverse the edit. Delete what you added, or restore the original lines. For example, suppose you added this to turn your post titles dark green:
.entry-title {
color: darkgreen;
}
Deleting that rule hands the styling back to whatever your theme specified elsewhere, which is usually exactly what you want. Careful, though: if another rule elsewhere also targets .entry-title (the theme’s own stylesheet, a plugin, the Customizer), deleting your line might not recreate the exact “before” look by itself. CSS is layered like that, and sometimes you need to restore the original line rather than just remove yours.
Step 5. Update the file and reload the pages you were working on.
Honest caveat: the editor doesn’t reliably keep saved versions. If you can’t reconstruct the original code from memory, don’t guess. Grab a backup or a clean copy of the same theme version and compare.
The Reset Button: Reinstall the Theme
Best for: damaged theme files, especially when you haven’t customized much directly.
Reinstalling replaces the theme’s files with fresh copies straight from the source. The trade-off is obvious: any customizations you made directly in theme files go with them.
Step 1. Identify the theme. Under Appearance → Themes, note the active theme and whether it came from the WordPress.org directory, a premium developer, or a custom build.
Step 2. Back up first. Files and database. This one is non-negotiable, because reinstallation can wipe out direct theme edits.
Step 3. Download a clean copy. Get the theme from its official source: the WordPress.org directory for free themes, the developer’s own site or account for premium ones. Grab the same version you’re running now if you can, so file comparisons actually mean something.
Step 4. Replace the files. Use the theme’s supported update or reinstall flow if it has one, or overwrite the damaged files through the file manager or SFTP. Don’t blindly overwrite everything, especially if the theme contains custom code or the replacement is a different version.
Step 5. Test. Layout, navigation menus, widgets, whatever custom functionality the theme provides. If the problem survives a reinstall, the cause is probably elsewhere: a plugin, a setting stored in the database, a child theme, or something else entirely.
One note: reinstalling doesn’t reset everything. Settings saved in the database, Customizer changes, and separate child themes usually survive the process untouched.
The Classic Disaster: Fixing a Fatal Error in functions.php
functions.php breaks more WordPress sites than any other theme file. It’s where everyone pastes snippets, and PHP gives you zero margin for error: a missing semicolon, an unbalanced brace, an invalid statement, a function your theme doesn’t expect, and the whole site goes down.
Step 1. Check whether the dashboard still loads. Try https://yourwebsite.com/wp-admin. If it loads, look for the recovery-mode email WordPress sent to the admin address and follow its instructions. If the dashboard is gone too, move to the file manager or SFTP as described above.
Step 2. Open the file. wp-content/themes/your-active-theme/functions.php. Download a copy before editing anything.
Step 3. Look hard at your latest change. The usual suspects:
- A missing semicolon.
- Braces or parentheses that don’t match.
- A misspelled function name.
- The same function declared twice.
- A call to a function that doesn’t exist.
- Code that collides with a plugin or with the theme’s own functions.
Step 4. Cut or restore. Remove the bad addition, or restore the original block from your backup. Whatever you do, don’t empty the whole file. Themes rely on what’s inside functions.php to boot.
Step 5. Test, then test properly. Reload the site and see whether the error cleared. If it persists, check the debugging logs, ideally on a staging site, and never with detailed PHP errors switched on for public visitors. WordPress’s own debugging guide lives here: https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
Not Everything Lives in Theme Files: The Customizer
Here’s a trap worth knowing about. Some changes never touch theme files at all. Colors, logos, and header layouts set through the Customizer are stored in the database. If your site changed after you poked around the Customizer, restoring a file won’t undo any of it.
To check:
- Open the dashboard.
- Go to Appearance → Customize, if your theme offers it.
- Find the setting you changed.
- Put back the previous value, or pick the original option.
- Click Publish.
The exact options depend on your theme. And if you run a block theme, most design decisions live in Appearance → Editor rather than the classic Customizer, so look there and restore the template, template part, or global style you changed.
The Theme File Editor, the Customizer, and the Site Editor are three different tools writing to three different places. Figuring out which one you actually used is half the battle.
No Backup? You Still Have Options
So you edited the theme with no backup. It happens to everyone eventually. Work through these in order.
Ask your host. Plenty of hosts keep automatic backups on their own schedule. Check the control panel or ask support whether a restore point exists from before your edit, and whether they can restore a single file instead of the whole site.
Check your own computer. Did you ever download the theme? Save the code into a text file? Use a code editor that keeps local history? Search your machine for the theme folder or the name of the file you edited.
Download a clean copy of the theme. If the theme is publicly available, grab the same version from its official source, compare it against your modified file, and restore just the broken portions. This works poorly for custom themes or heavily modified ones, for obvious reasons.
Check version control. If a developer set the site up with Git or another version-control system, your original code may be sitting in an earlier commit. Any developer can diff the versions and pull back exactly what you lost.
Call for help. Site down, cause unknown, no leads? Contact your host or a WordPress developer and hand them the error message, the affected file, and a summary of what you changed. What you shouldn’t do is keep editing blindly. Every additional change makes the eventual repair harder.
Mistakes People Make While Fixing Their Fix
Recovery work has its own footguns. Watch for these.
Fixing without a backup. Download the file before you repair it. Even if you’re sure. Especially if you’re sure.
Replacing the whole theme when one file broke. Wholesale replacement can throw away customizations or drag in a different version with new quirks. Restore the file, not the theme, whenever you can.
Emptying functions.php. That file often carries essential setup: image sizes, script and style registrations, theme supports, the works. Remove the bad code, keep the good.
Blaming the fix when it’s the cache. Cached CSS or HTML will happily show you the old, broken version of your site long after the repair. Purge the caches before you decide the fix failed.
Editing the parent theme for permanent changes. The next theme update overwrites everything you did. For ongoing customization, use a child theme or another maintainable approach.
Restoring a full backup without checking its date. A full restore rewinds the database too: posts, orders, users, everything back to the backup date. Look before you leap.
Keeping This From Happening Again
Recovery skills are great. Not needing them is better.
Back up on a schedule. Files and database, stored somewhere that isn’t your own server, and actually test a restore now and then. An untested backup is a hope, not a plan.
Use a staging site. A staging copy lets you break things where nobody’s watching. Test the snippet there, confirm nothing explodes, then move it to the live site.
Use a child theme. Child themes keep your customizations separate from the parent theme, so updates don’t erase them. They’re the right home for template edits and theme-specific PHP. They are not a backup substitute, and they don’t fit every kind of customization, but they solve the biggest problem.
Prefer custom CSS tools when they’re enough. Small design tweaks belong in the Customizer’s Additional CSS, or the global styling interface in block themes, not in style.css itself. Less file editing means fewer chances to break something. For heavier customizations, use a child theme or a maintained custom-code solution.
Change one thing at a time. Make an edit, test, repeat. When you stack five changes before testing, you get to enjoy not knowing which one broke the site.
Keep everything updated. WordPress, themes, plugins, on supported and compatible versions. Take a backup before major updates and give them a spin on staging first.
Consider locking the editor. On a production site, you can switch the built-in file editors off entirely. Add this line to wp-config.php above the line that reads “That’s all, stop editing!”:
define( ‘DISALLOW_FILE_EDIT’, true );
That removes the theme and plugin editors from the dashboard. It doesn’t stop anyone with file manager, FTP/SFTP, or other administrative access, but it does protect against fat-fingered moments in wp-admin. Fair warning: editing wp-config.php carries its own risk. A syntax error there can take the whole site down, so back the file up first and only do this if you’re comfortable editing it.
Frequently Asked Questions
Can I undo a saved theme editor change with Ctrl + Z? No. Ctrl + Z works inside your current editing session, and even then it depends on your browser. Once you’ve clicked Update File, the change is on the server. Saved edits get reversed with a backup, a clean copy of the file, or version control.
Does WordPress keep a history of theme file versions? The built-in Theme File Editor doesn’t give you a proper version history of saved files. For a rewind button you need a backup, your host’s restore service, a fresh copy of the theme, or Git.
How do I get my original theme back? Depends on what changed. File edits come back from a backup or a clean copy of the correct theme version. Customizer or Site Editor changes have to be reset through those tools, since they live in the database.
My site crashed right after I edited functions.php. What now? Get in through your host’s file manager or SFTP, save a copy of the file, then remove the bad code or restore a clean version. If you can’t spot the problem, check the error logs or bring in your host’s support team.
Will reinstalling my theme delete my posts and pages? No. Posts and pages live in the database and survive a theme reinstall. What you can lose is direct edits to theme files, and some theme-specific settings may behave differently afterward. Back up fully before you reinstall.
How do I undo a CSS change in WordPress? Open wherever that CSS was added, compare it to the original, and delete or reverse the unwanted rules. And remember CSS can come from more places than style.css: a child theme, a plugin, the Customizer, the Site Editor, even a caching or optimization plugin.
Can I recover a site with no backup at all? Often, yes. Try the host’s automatic backups, a clean theme download, local copies on your computer, or version control. If none of those exist, the affected code has to be repaired by hand.
Should I be editing theme files directly at all? If you read code comfortably and you take a backup first, sometimes. On a live site it’s the riskiest way to customize. A staging site, a child theme, the Additional CSS field, or a maintained code-snippets solution will do the same job with a safety net.
Final Thoughts:
Knowing how to undo theme editor changes in WordPress is one of those skills you hope never to use and are glad to have. Backups make most recoveries a five-minute job. When the dashboard is down, the file manager or SFTP gets you back in. Small mistakes can be reversed in the editor itself, and a reinstall handles genuinely damaged files.
But the real lesson is boring and true: back up before you edit. Regular backups, a staging site for testing, a child theme for customizations, and one-change-at-a-time discipline will prevent almost every theme disaster you’d otherwise spend an evening fixing.
If you’re staring at a broken site right now, do two things: identify the file you last edited, and find out whether a clean backup exists. Those two facts point you to the safest way back.