WordPress cannot modify header information

If you’re seeing a “Cannot Modify Header Information” error, chances are it’s caused by having spaces before or after the opening(<?php) and closing(?>) tags in one of your php files.

Finding the error

You’ll probably see an error message like the one shown below. The message will tell you what file has the error and it will show the path to the file. In my case, my error is in the file “functions.php” located at the path “/wp-content/themes/jordanrodriguez/functions.php”. Log on to your server and open the file with the error.

Error message

Warning: Cannot modify header information - headers already sent by (output started at /home/html/wp-content/themes/jordanrodriguez/functions.php:463) in /home/html/wp-includes/option.php on line 568

Fixing the error

In addition to the “Cannot modify header information” error’s file path, you should also have a line number where the error has occurred. If the line number is low, the error is at the top of your php file and if it’s high, it’s most likely at the end of your file.

I’ve connected to my server and opened the “functions.php” file. I can see that there’s no space above the opening php code and I will now look at the bottom of my page.
modifyHeader1

It looks like I found the issue, there are three empty lines at the end of my php file. I will need to delete the lines and deploy the file back to my server. Once it’s deployed to the server, your issue should be fixed. If you are using any caching plugins make sure that you delete and rebuild the cache files so that the error is no longer displayed.
modifyHeader2