Warning: Cannot modify header information – headers already sent
READING TIME: MIN
Seen this one? Probably yes, if you are a regular WordPress user.
Headers already sent – explanation
As you probably know the web page usually consists of several parts which include a header, a body, and a footer. And in case that the page header is coded incorrectly or there is some sort of conflict between scripts then the following error can occur. The error is usually displayed on the site front-end and usually, there is a path that tells you the exact file that is producing the error and even on which line.
Possible solutions
Here are some fixes and checks that you can try yourself if you happened to stumble on this issue:
- Check for blank lines at the top of the file on which the issue occurs and also in the file wp-config.php. There should not be any blank lines or spaces before the opening PHP tag “<?PHP“. And also check for the same but this time after the closing PHP tag “?>”
- Check for spaces before or after the opening tag “<?php” and again check for any spaces before or after the closing tag “?>”. If the document does not have a closing tag make sure that there are no spaces after the last char of the file
- If the issue is with a core WordPress file you can simply try to replace it with a fresh copy of the file. If it is a part of a plugin you can deactivate, then completely delete the plugin and then re-install it again.
- Make sure that the file encoding is plain UTF-8
If you have used some custom code in some files and they are now outputting this error check for the following functions in the file:
header()
header_remove()
session_start()
session_regenerate_id()
setcookie()
setrawcookie()
If you have checked and tried all of the above and the issue still pops up then feel free to get in touch and we will further look into the matter.