Warning: Cannot modify header information – headers already sent

by Hui Wang

After adding several functions to the file functions.php, I get this warning when I try to install a plugin.

This is commonly known as the “whitespace problem”.

The error message typically looks something like

Warning: Cannot modify header information – headers already sent by (output started at /var/www/wordpress/wp-content/themes/yamidoo/functions.php:855) in /var/www/wordpress/wp-includes/pluggable.php on line 865

The solution is, obviously, to remove that whitespace from the file. Read the error message carefully. It says “output started at …” followed by a file name and a line number. That is the file (and line) that you need to edit. Ignore the second file name – that is only a file that included the file that has the whitespace. The first file is the one you have to edit, not the second one.

In my case, I removed the spaces between the end of the former file and codes added.

<?php } //end of the former file?>

hare are the whitespaces to be removed
<?php  //codes added ?>