Yesterday I almost became tensed. Some tutorials on the net are really lame! π I trusted a site and applied that tutorial directly on my blog, and the result became sh*t. I highly recommend you to try tutorials on a demo blog rather than on your primary site or blog.
Yesterday I came across this unique WordPress error titled “Cannot modify header information – headers already sent by …” [Without Quotes]
Though, this tutorial is 99.9% perfect, I recommend you to backup all your theme files before implementing this tutorial. Happy Blogging!
I’ll tell you what mistake I did and how to resolve that.. 8)
Description :
You get a warning message on your browser that says:
Warning: Cannot modify header information – headers already sent by (output started at
Example :
Reason :
The reason is simply simple. It is usually because there are spaces, new lines, or other garbage before an opening < ?php tag or after a closing ?> tag, most probably in wp-config.php. It may also occur in other files too, so please check the error message. Many editors are adding additional blanks (spaces) and empty lines at the end of a file when you edit it.
Solution :
The best solution I would say is to replace the corrupted file with the file you have in your backup. You can also try the following alternative steps!
#1 – Download the file mentioned in the error message.
#2 – Now open that file using a really good Text Editor. It should be a plain text editor. I highly recommend Notepad++ or TextWrangler.
P.S. Don’t risk. Avoid Notepad, WordPad and even MS Word.
#3 – Now check that the very first characters are < ?php and the very last characters are ?>
Most Important!
You should save your file either as ANSI/ISO-8859 or as Unicode without BOM. Don’t ever save in normal format.
Have you ever faced this problem? Do you any other solution for solving this?
Thanks Kumar! Iβve been getting those errors in a couple of little websites. Now I know what the heck is going on and have written on it also
Wow, Thank you very much. I got the same problem but in pluggable.php file. But which ever the file is the solution is exactly what you said. Its only the empty lines at end of the file.
Great post. Just received this error for the first time and couldn’t figure out why. I had copied some code to a functions.php file from another tutorial and it must have included some hidden spaces. Thanks for helping me fix it.
recently i had feed errors
This is one of the most common problems which I faced when I was updating or tweaking my blog. All the times, I used to deactivate the newly being used plugin and try to refresh the page which used to work perfectly.
This is a minute thing which I missed and you have covered very well in this post.
Never faced such an issue.
Nice tips, I have not seen this type of error message on my blog, thanks for sharing the solution, I now know the error and how to resolved it, if such error occur in my blog.
these things happen in WP , thats why im on blogger now , with low seo space
Yep, i learned this the hard way as well, now i always try upgrade, experiements and sometimes even new plugins on my smaller and less important blogs. Messing up the main blog give a heart attack sort of a feeling π
i had faced a similar problem, thanks to my exceptional coding talent, i never bothered/dared to do more editing, i uploaded the file from the backup and things were all right.
Pradeep I have seen your site behaving abnormally when you were making the change.
Glad that it is fine now.
Nice tut BTW.
Nice post and fantastic job done.First time came to know so many errors code and meaning. How to take care of them ill be easy if you understand them.Back up your thing always safe than lost.Thanks for knowledge sharing specially for those who are using wordpress stuffs.
I have faced this weird problem while I was developing my theme. It got solved by re-arranging the header content then.
Haha… Man, how many times you don’t get this problem? Today, while installing a new plugin, I got into a little bit adventurous mode and started editing without a backup on notepad. Finally it turned out that the crappy notepad put some extra characters before the open php tag. It wasn’t visible in UTF encoding but when I switched to unicode, those little monsters appeared.. Very useful post man.
I too faced this problem when I was designing wordpress theme and I solved the problem by removing white spaces only.
Well I have not see such type of error on my blog till now. If I get any problem I will discuss with you.
So far no, but i am sure this will help me in future when i face such errors. Seeking for valid source of problem solving is highly recommended.
Cheers.
– Robin
I've faced it and had no clue, thanks man!
Sometimes small mistake in code can be fatal.We should always backup theme before editing it otherwise we can get into trouble.
Nice work mate!! I’ll seek your help if I overcome any WordPress error like this, ;)..
Before that, I think you did some editing work in your WP, May i know what you did?? & Why you got this error??
I’ve got this problem, but I have replaced the core files… This tutorial makes it easy. Thanks
cool article mate!!!!
Its good that you are posting these sort of articles related to wordpress these are really usefull π π