Cannot modify header information – headers already sent by… WordPress Issue

When running script, I am getting several errors like this:

Warning: Cannot modify header information – headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23


Possible solutions

  1. header("Location: $location", true, $status);


    echo "<meta http-equiv='refresh' content='0;url=$location' />";
  2. Most of this trouble comes up because of undesirable whitespace(s) somewhere before the first "<?" and after the last "?>" in a php script. Use Notepad2 or something to edit code and better try to use in-built on-line theme editor in the admin console. Try to find and eliminate all undesidrable whitespaces in every theme’s php file and resave those files.
  3. The long term answer is that all output from your PHP scripts should be buffered in variables. This includes headers and body output. Then at the end of your scripts do any output you need.

    The very quick fix for your problem will be to add

      // code