Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've created quite a few custom websites but I've come across this problem with various addons/plugins or just general code. How can I avoid the "headers already sent" error?

I've tried to put the code as far up in the header.php file as possible but have never managed to get around the error. Is there an easier way to avoid it?

My latest bit of code that's getting the error is using the html2pdf script.

It always happens in the header.php file, I've removed all extra spaces etc and made sure it's unicode-8 etc but just cannot get rid of the problem in the header.php file.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

See WordPress codex page - FAQ Troubleshooting

share|improve this answer
    
I've tried all that but surely there's an easier way? –  Rob Dec 5 '11 at 11:49
    
And it didn't help? –  Mamaduka Dec 5 '11 at 11:53
    
The problems are in the header.php file from the default WP install. I've removed all the extra lines and spaces but it doesn't seem to do anything. In fact the problem starts on line 8 which is <html xmlns="w3.org/1999/xhtml"; <?php language_attributes(); ?>> –  Rob Dec 5 '11 at 11:55
add comment

Mamaduka is right and he pointed you to the right location. the problem is the extra characters . What you seem to not understand , is that the problem is REPORTED by header.php, but it can be generated from ANY theme file or plugin file ...

If you will install the default wordpress installation, you will see that no error occur - it occurs only if you install a different theme / plugin, and or make changes to files .

so actually, you need to check ALL your theme files and ALL your plugin files for extra characters, and / or lines and/or empty characters/tabs.

Unfortunately, since it does not occur on ALL servers , many theme/plugins developers do not know this problem.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.