FunctionalityChatGPT code

ChatGPT code in functions.php crashed your WordPress site

You pasted a snippet from ChatGPT into functions.php and now the site shows a white screen or "There has been a critical error". You can get it back in a few minutes.

  • Difficulty: Easy
  • Time: 10 to 30 minutes
  • Updated October 28, 2026

Symptoms

  • The site shows a blank white page
  • You see "There has been a critical error on this website"
  • You cannot log in to the dashboard anymore
  • It started right after you saved functions.php

Why it happens

functions.php runs on every page load. One missing bracket, a function name that already exists, or code written for a different setup is enough to stop the whole site.

ChatGPT writes code that looks right, but it cannot see your site. It does not know which plugins you use, which PHP version runs on your server or which function names are already taken.

The fix is to remove the code without the dashboard, then add it back in a safer way if you still need it.

Try this first

  1. Check your email for a recovery link

    WordPress often sends the admin email a message titled “Your Site is Experiencing a Technical Issue”. It has a link that logs you in with the broken code paused. Use it if you have it.

  2. Open the file without the dashboard

    Log in to your hosting control panel and open the File Manager, or connect with FTP. Go to wp-content/themes/your-theme/ and open functions.php.

  3. Remove the code you pasted

    Delete the snippet you added, save the file and reload the site. If you are not sure where it starts, compare with a backup or with a fresh copy of the theme.

  4. Turn on the error log if it still fails

    Add these lines to wp-config.php, above the line that says “That’s all, stop editing”. Errors will be saved to wp-content/debug.log, where you can see the exact file and line.

    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
  5. Add code in a safer place next time

    Use a snippets plugin like Code Snippets, or a small custom plugin. They can switch off broken code on their own, and your changes survive theme updates. Turn WP_DEBUG back off when you are done.

When to stop and call a person

Call a person if you cannot reach the files, if the site still fails after the code is gone, or if you need the feature the snippet was meant to add. A developer can write it properly and test it on a copy of the site first.

Request a repair crew

Questions people ask

Why did the snippet work for someone else?

Their site had different plugins, a different theme or a different PHP version. Code from chat tools is written for an average site, not yours.

Will I lose content when I fix this?

No. Your posts and pages live in the database. Removing code from functions.php does not touch them.

Related fixes