C:\ Home » Blog » Tech » How To Fix functions.php Header Redirect Errors & White Screen On WordPress

How To Fix functions.php Header Redirect Errors & White Screen On WordPress

Since I upgraded servers last week, I've had some issues with the blog. First I had issues with DNS entries, then my IP, then the functions.php file of my theme.

The front-end worked fine, it seemed, yet for every action you performed - both in back and front-end, the headers wouldn't redirect, and you'd just receive a white screen, and no message (because of course I don't have debug turned on for users). Fortunately, in most cases whatever you had done had worked, but you didn't know it until you went back and refreshed the page. For example: posting a comment, or editing a post.

Some more advanced functions that rely on (I assume) multiple redirects to work at all... didn't work at all! Things like searching for a post, or loading the media manager, or updating a plugin, or the most annoying thing: logging in!

The firewall went haywrite as soon as I tried, so I tried disabling the firewall. It still wouldn't work.

Eventually I turned on debug, and received some weird error messages regarding the functions.php file - it spoke of various lines where these errors persisted, yet I could find no errors in these specific lines. I tried removing certain portions of the file to no ado, and eventually I tried removing the file entirely, and it worked! So, was the file to blame? I tried disabling all plugins, and re-uploading the file, but that didn't work either. Yes, functions.php was the problem.

Unfortunately, a large portion of the functions on my site depend on this file - like the navigation and breadcrumbs. Without it nothing short of the logo loads, so removing the file wasn't an option. I removed the file while logging in, and then uploaded the file again afterwards, and tried working with various things within the admin section, as I usually do, with varying degrees of success.

This was just a temporary fix, of course. I did some research, and eventually stumbled upon this post, speaking of how you could make a plugin out of your functions.php file. Maybe this could resolve the issue? I gave it a try, and unfortunately it did not.

What it did do, however, was give me an error message I could troubleshoot! Looking back, said error message might have been useful reference for this post, but the gest of it was this: there was something wrong with the file, and it might result in headers not forwarding correctly. I Googled the error code, and I found the solution. Perfect.

There was more than one solution, but in my case it was as simple as converting my functions.php file from UTF-8 encoding to ANSI. Piece of cake. I opened the file via Notepad, and saved it again with the new encoding, uploaded it, aaaand no more error messages!!

To see if this is your issue or not, you can easily move over your functions to a plugin (just follow the link above - it's super simple), and then activate it to see which error code you get. Apply the fix, re-upload the plugin file, deactivate it, and activate it again, and if the error is gone you're all set!

This turned into more of a ramble than the step-by-step guide I had planned, but hopefully it might be of use for those who, like me, get the initial error message and have no idea what to do about it. Thus the elaborate title with the search words I'd search for included. Hope it comes in handy, and if not: check for empty spaces before or after your opening PHP tags. That seems to be the most common cause.


Keep track of the discussion via rss? Read about comment etiquette? Or type in something below!
This was pretty damn interesting. And yet, nobody's spoken! Be the first!

The Comment Form

Your email address will not be published. Required fields are marked *

Your email is saved only to approve your future comments automatically (assuming you really are a human). ;) It's not visible or shared with anyone. You can read about how we handle your info here.

Question   Razz  Sad   Smile  Redface  Biggrin  Surprised  Eek   Confused   Cool  Mad   Twisted  Rolleyes   Wink  Idea  Neutral

Privacy   Copyright   Sitemap   Statistics   RSS Feed   Valid XHTML   Valid CSS   Standards

© 2022
Keeping the world since 2004.