How to Recover from a functions php Fatal Error in WordPress

WordPress | Updated July 2026

You pasted a code snippet into your theme's functions.php from the WordPress dashboard, hit save, and now the entire site is gone. The front end shows a blank page or a critical error message, and wp-admin will not load either, so you cannot even undo what you just did. This is one of the most common ways to lock yourself out of WordPress, and on any Ultra Web Hosting account it is completely recoverable in a few minutes once you know that the fix happens outside WordPress, in cPanel File Manager or over FTP.

Do Not Skip This

Never Edit functions.php Live Again

The Appearance > Theme File Editor is the single most dangerous button in WordPress. One missing brace or semicolon in functions.php white-screens your entire site and the very editor you used to make the change. After you recover, stop using that editor and add custom code with a snippets plugin or a child theme instead.

  • Symptom: front end and wp-admin both down at once
  • Cause: a syntax or fatal error in functions.php
  • Fix now: revert the file over FTP or File Manager
  • Prevent: use a snippets plugin or child theme going forward

01. What Just Happened

The sequence is almost always the same. You found a tutorial that said "add this to your theme's functions.php," you opened Appearance > Theme File Editor in wp-admin, pasted the snippet at the bottom, and clicked Update File. The moment you saved, WordPress tried to load the file, hit a fault, and stopped.

Depending on your WordPress version and settings, you now see one of these:

  • A completely blank white page with no text at all (the classic White Screen of Death).
  • The message "There has been a critical error on this website", sometimes with a line about checking your admin email inbox.
  • A raw PHP error printed at the top of the page, such as Parse error: syntax error or Fatal error, naming functions.php and a line number.

All three are the same underlying problem: the code you added broke functions.php, and because that file runs on every request, it took down the front end and wp-admin together. Nothing is lost. The database, your posts, your uploads, and the rest of the theme are all fine. You just need to remove or fix the code you added.

Which Symptom Did You Get

If you are seeing the critical error page, our guide How to Fix There Has Been a Critical Error on This Website covers that exact message in depth. If you got a truly blank page, How to Fix the WordPress White Screen of Death walks through the wider set of causes. This article focuses specifically on the functions.php case, which is the most frequent trigger for both.

02. Why Editing functions.php From the Dashboard Is Risky

WordPress loads your active theme's functions.php on every page load, in both the front end and the admin area, before it renders anything. It is not like editing a post, where a mistake only affects that one post. A single character out of place in functions.php stops PHP from parsing the file, and PHP refuses to run a file it cannot parse. There is no partial loading and no "ignore the broken part."

Here is the cruel part. The built-in Theme File Editor is inside wp-admin. When your bad save takes down wp-admin along with the site, you can no longer reach the editor you were just using. You cannot click undo. That is how a two-line snippet locks you out of your own site.

The most common mistakes are tiny:

  • A missing semicolon at the end of a line.
  • A missing or extra closing brace } so the braces no longer balance.
  • An extra PHP open tag <?php pasted in the middle of a file that is already in PHP mode.
  • Calling a function name that already exists, which throws a "Cannot redeclare" fatal error.
Never Edit functions.php Live Without a Backup

Do not touch functions.php from the dashboard on a live site without a current backup and a way in over FTP or File Manager. WordPress does not lint the file before saving it, so it will happily let you save code that instantly breaks the site. If you are going to experiment, do it on a staging copy, not on the site your visitors and customers are using.

03. Read the Actual Error and Find the Line Number

Before you start deleting things, it helps to know exactly what broke. WordPress hides errors from visitors by default, so a blank page tells you nothing on its own. There are two ways to see the real message.

Option A: Turn on WP_DEBUG

Open wp-config.php in the root of your site (through File Manager or FTP, since you cannot reach the dashboard) and find the line that reads define('WP_DEBUG', false);. Change it to enable debugging and log to a file:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Reload the site once. WordPress writes the error to wp-content/debug.log. Open that file and look at the last few lines.

Option B: Read the server error log

In cPanel, open Errors (under the Metrics section) or look at the error log in your site's directory. The relevant line looks like this:

PHP Parse error: syntax error, unexpected end of file
in /home/youruser/public_html/wp-content/themes/your-theme/functions.php on line 214

That last part is what you want. It names functions.php and a line number. The real problem is usually on that line or the one just above it. "Unexpected end of file" almost always means a brace was never closed. "Unexpected" followed by a token usually means a missing semicolon or a stray character right before it.

Note

Turn WP_DEBUG back to false once you are done. You do not want debug logging running on a production site long term, both for performance and because the log can leak paths. Remember to delete wp-content/debug.log afterward as well.

04. The Fix: Edit functions.php Outside WordPress

The whole recovery comes down to one idea: since WordPress will not load, you edit the file with a tool that does not need WordPress. You have two options, and both reach the same file.

Also Fine

FTP or SFTP

Connect with an FTP client such as FileZilla, download functions.php, edit it locally in a real code editor, and upload it back over the top.

  • Use your favorite desktop editor
  • Good if you already have FTP set up
  • Keeps a local copy as you work

Whichever you choose, the target is the same path: wp-content/themes/your-theme/functions.php, where your-theme is the folder name of your active theme. Once the file is open, you either delete the snippet you added or fix the syntax the error pointed at, then save. That is the entire fix.

05. Step by Step in cPanel File Manager

This is the fastest path for most people. You do not need any software beyond your browser.

  1. Log in to cPanel and open File Manager (under the Files section).
  2. Navigate into public_html (or the subfolder your WordPress install lives in), then into wp-content, then themes.
  3. Open the folder for your active theme. If you are not sure which one is active, it is the theme you were editing, and it is usually the one with the most recent modified date. Avoid folders named with a trailing -child unless that is the theme you edited.
  4. Click functions.php once to select it, then click Edit in the top toolbar. If a character-encoding prompt appears, click Edit to continue.
  5. Scroll to the bottom of the file, or jump to the line number from the error in Section 03. Find the code you pasted in earlier.
  6. Delete the snippet you added, exactly the lines you pasted and nothing else. If you are fixing rather than removing, correct the missing semicolon or brace the error pointed at.
  7. Click Save Changes in the top right.
  8. Reload your site in a new tab. The front end and wp-admin should both come straight back.
Make a Backup First

Before you edit, use the File Manager Copy button to duplicate functions.php to something like functions.php.bak in the same folder. If your edit does not fix it, you can copy the original back and try again. This takes five seconds and saves a lot of grief.

06. If You Cannot Spot the Bad Code: Restore a Clean Copy

Sometimes you cannot tell what is wrong, or you edited more than you remember. In that case, stop trying to fix it line by line and just put a known-good copy of functions.php back.

  1. From a backup: if you have a backup of the site from before the change (a cPanel backup, a backup plugin archive, or a copy you made), pull functions.php out of it and drop it over the broken one.
  2. From a fresh theme download: if you did not customize functions.php before this edit, download a clean copy of your theme from the developer or the WordPress theme directory, unzip it, and upload its functions.php over yours. This replaces the file with the untouched original.
  3. Then re-add your change carefully: once the site is back, if you still want that snippet, add it the safe way described in Section 08 rather than pasting it back into functions.php.
Watch the Theme Version

If you download a clean functions.php, make sure it matches the exact version of the theme you have installed. A functions.php from a newer or older release can reference functions or hooks that do not line up with the rest of your theme files. When in doubt, restore from your own backup instead, since that is guaranteed to match.

07. Recovery Mode: WordPress May Email You a Link

Modern WordPress has a built-in safety net called Recovery Mode. When a fatal error takes down the site, WordPress often emails the site admin address a special link that lets you log in to a limited dashboard with the broken code paused, so you can deactivate the offending plugin or theme without touching files.

  1. Check the inbox for the admin email set in WordPress (Settings > General). Look for a message with a subject like "Your Site is Experiencing a Technical Issue."
  2. Click the Recovery Mode link in that email. It logs you into a stripped-down wp-admin.
  3. WordPress usually names the file and function that caused the fault, which confirms it is your functions.php edit.

Recovery Mode is genuinely useful when a plugin caused the crash, because you can deactivate the plugin from there. For a theme's functions.php it is less direct, since you often still need to edit the file. But the email is the fastest way to confirm what broke. If no email arrived, it is usually because WordPress could not send mail or the admin address is wrong, in which case fall back to the File Manager fix in Section 05.

More on the Critical Error Page

Our guide How to Fix There Has Been a Critical Error on This Website covers Recovery Mode in full, including what to do when the email never arrives and how to set a working admin address so it does next time.

08. The Right Way to Add Custom Code From Now On

Once you are back online, the goal is to never end up here again. The dashboard Theme File Editor exists, but treating it as your code editor is how sites break. There are three safer patterns, in rough order of how much most people should reach for them.

Risky

Editing functions.php Directly

Pasting code straight into the theme's functions.php from the dashboard. A single typo takes the whole site and wp-admin down, with no undo and no warning before you save.

  • No syntax checking before save
  • One error locks you out entirely
  • Changes are wiped by theme updates

Use a code snippets plugin

A snippets plugin (the popular free ones are well maintained) gives you a place to store small PHP additions with a built-in safety check. When you save a snippet that has a fatal error, the plugin detects it, deactivates that one snippet, and shows you the error, all without taking the site down. That alone removes the main risk of functions.php editing.

Use a site-specific plugin

For anything more than a couple of snippets, wrap your custom code in a tiny "site-specific" plugin: a single PHP file in wp-content/plugins with a plugin header. Your code then lives independent of any theme, and if it ever breaks the site, you can deactivate it by renaming its folder over FTP, which is far simpler than surgery on functions.php.

Use a child theme

If your customizations are theme-related (template overrides, theme-specific hooks), a child theme is the correct home. A child theme has its own functions.php, so your code is safe from parent theme updates, and you get the same isolation benefit.

Always Test on Staging

Whichever method you use, try new code on a staging copy of the site first, not on production. A staging site is a private clone where a mistake affects nobody. Our guide How to Set Up a WordPress Staging Site walks through creating one in a few clicks so you always have a safe place to experiment before pushing changes live.

Locked Out and Not Sure Where to Start?

If your site is down from a functions.php edit and you would rather have us revert it, open a ticket. Tell us the site and roughly what you added, and our team can restore the file from a backup and get you back online, then help you set up a safer way to add code.

Open a Support Ticket

09. When the Error Was Not Yours

Not every functions.php fatal error comes from a snippet you pasted. If the site went down without you touching the editor, consider these:

  • A theme update shipped a functions.php that conflicts with a plugin or with your PHP version. Restoring the previous version, or updating the conflicting plugin, usually clears it.
  • A PHP version change on the server can surface errors in older theme code that used to run. Check which PHP version your account uses in cPanel and test an earlier one if a recent switch lines up with the breakage.
  • Malware modified functions.php. Injected code at the top or bottom of the file, especially base64 blobs or code you do not recognize, is a red flag. If you find that, treat the site as compromised.
If You Suspect a Hack

Strange code you did not add in functions.php (or in wp-config.php, or scattered across theme files) means the site may be breached, not just misedited. Do not just delete the visible snippet and move on. Follow our full cleanup process in How to Fix a Hacked WordPress Site to find and remove everything, and change all passwords afterward.

For the broader class of "site returns an error page" problems that are not specifically functions.php, our How to Fix the WordPress HTTP 500 Internal Server Error guide covers server-level causes such as a broken .htaccess or a hit PHP memory limit. And once you are stable again, How to Optimize WordPress Performance and How to Install WordPress are good next reads if you are rebuilding or hardening the site.

Quick Recap: Recovering From a functions.php Error

If you only remember six things from this guide, remember these:

  1. Do not panic and nothing is lost. Your database, posts, and uploads are fine. Only the theme file is broken.
  2. The fix happens outside WordPress. Since wp-admin is down too, use cPanel File Manager or FTP, not the dashboard.
  3. Edit wp-content/themes/your-theme/functions.php and delete or correct the code you added, then save and reload.
  4. Read the error for the line number. Turn on WP_DEBUG or check the cPanel error log to see exactly what broke and where.
  5. Cannot spot it? Restore a clean copy of functions.php from a backup or a fresh theme download that matches your version.
  6. Never edit functions.php live again. Use a snippets plugin, a site-specific plugin, or a child theme, and test on staging first.

Last updated July 2026 · Browse all WordPress articles

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Migrate a WordPress Site to Ultra Web Hosting

WordPress | Updated July 2026 Moving a WordPress site to Ultra Web Hosting is one of the most...

504 Error - Are You Sure You Want to Do This?

WordPress | Updated March 2026 The "Are you sure you want to do this?" message in WordPress...

Quickly Disable All WordPress Plugins via phpMyAdmin

WordPress | Updated 2026 If a WordPress plugin is causing your site to crash, show a white...

How to Move a Weebly Site to WordPress

WordPress | Updated July 2026 There is no automatic importer that turns a Weebly site into a...

JetPack says my website is offline

WordPress | Updated 2026 Quick Answer JetPack's uptime monitor can report false "offline"...



Save 30% on web hosting - Use coupon code Hosting30