WordPress: Cannot Modify Header Information

  • Buffer
  • Sharebar
  • Buffer

I have created and edit the templates for my WordPress blog long enough to come across a few confusing errors. While I have had good success solving many of the errors fairly quickly, there is one that has continuously come up, and caused my blog from loading.

Recently, however, I managed to find the cause of this common error, and since then have quickly corrected any problems that have caused the error. This post explains the error, and how I solved the problem.

The Error

Sometimes when I edit my WordPress template files, I receive the following error message when I attempt to view my blog:

Warning: Cannot modify header information – headers already sent by (output started at [path to problem file]) in [last file requested] on line [line number]

The text in italics is dynamic and is different depending on the files and line numbers that caused the error.

For someone like me, who isn’t very fluent in PHP, errrors such as this are very cryptic. At least the error message did mention two files that I could look into to see if I could find the problem.

The Solution

The first thing I did was look into the first file specified by the error message. I slowly looked through the file, looking for anything that didn’t look right. Nothing in the code jumped out at me as being wrong. I then closed the file and looked for the second file specified in the message.

The second file, however, was a WordPress file as I had been editing my template in WordPress. Realizing that the WordPress file was probably not the cause of the problem, or I would have had the error once I upgraded, I re-opened the original file.

After reviewing the contents of the file a second time, I thought maybe some strange characters were embedded in the file. I double-checked the spaces and carriage returns, and then saved the file.

The error still came up in the web browser. I went back to the file and removed all lines and characters from the end of the file (below the ‘?>’ tag), and then resaved the file. After doing that last step, the pages to my blog were displayed again without any problems.

If you experience the same error, check to ensure you don’t have any strange characters after the ‘?>’ tag at the bottom of a file.



WordPress Bible (Paperback)

By (author) Aaron Brazell

List Price:$49.99 USD
New From:$5.83 In Stock
Used from:$1.87 In Stock

buyamzon button Wordpress: Cannot Modify Header Information

You may also like:

Wordpress Logo

WordPress Error: Allowed Memory Size

Wordpress Logo

Correcting ThickBox Path in WordPress

Wordpress Logo

New WordPress Theme – Slow Performance

Wordpress Logo

Finding and Fixing 404 Errors on Your WordPress Blog

5 people had something to say about “WordPress: Cannot Modify Header Information”:

Comments


  1. never happened to me but thanks for heads up…


  2. I limp along with my WP blog, doing most things right, but one thing I don’t like and don’t know how to fix is how to get rid of the extra blog name line below my tabs. I know enough to back up my blog before doing anything, but I don’t know which section in the places to edit the the blog (header, index, etc.) holds the code for the part I want to eliminate. Even WP for Dummies is no help! LOL I don’t want you to solve my problem for me, but maybe do an article about it?


    • It looks like it appears on all your pages so chances are it is in one of the more common files. Try looking in the header.php file of your theme. More specifically, you should be look for a line that contains:

      <div id=”header”><h1><a href=”http://ipentimento.com” title=”iPentimento | Genealogy and History home page”>iPentimento | Genealogy and History</a></h1></div>


  3. I remember when I first saw that error I didn’t know what the heck was going on. Took me forever to realize it was an empty line after the ?> that was causing it. BTW, just came here after reading on WB you no longer use fluid widths. I absolutely LOVE this design. It’s my favorite TE look thus far. Nice job!
    Twitter:


    • Thanks Lisa. I visited a number of blogs to see what I like before designing the template. I learned a bit more about WordPress when I designed this one, but there is still some more work to do.

Do you have something to say? Let everyone know!

Commenting policy: All comments are moderated for spam. You must use your real name and not your website name or keywords. If a comment is deemed to be spam, then it will be deleted or edited. Links to your website within the comment body is not permitted, but you are free to use CommentLuv to add a link to your latest post. If you wish to add a link to your website, you can always contact me about submitting a guest post.






CommentLuv badge
This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 5 approved comments. Use your real name and then @ your keywords (maximum of 3)

Previous Post:

Next Post: