How to Fix “Cannot modify header information – headers already sent” error in WordPress

A most frequent question comes while wordpress troubleshooting is, after adding some code to functions.php or after replacing / modifying any file by using the FTP, we get an error like below,

Warning: Cannot modify header information – headers already sent by (output started at /your/site/path/public_html/index.php:724) in /your/site/path/public_html/blog/somefile.php on line 98

It means that there is anything came before the headers part of the PHP. For example text or the spaces have same before or after (Start Tag) <?php or ?> (ending tag).

Tip : You can get the error information, by visiting to Home of your FTP Server and look for the file named error_log, just download and view it.

Now open that errorfile.php either by downloading it from FTP or open it directly from your File Manager, and look at the starting portion, and remove all extra content like spaces, but if you get something HTML tags like  <div id=”TipsRing”> then don’t delete them.

How to Fix Cannot modify header information - headers already sent error in WordPress

How to Fix Cannot modify header information   headers already sent error in WordPress

Now go to the end of that error generating file and delete all blank spaces after the ?> sign.

How to Fix Cannot modify header information   headers already sent error in WordPress

You can replace that file with your new one (edited) either by using the FTP or in the File Manager itself. But remember to backup your old files first.

Enjoy!

Leave a Reply

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