× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

WordPress "Headers already sent" - the most likely solution to this problem

Aaron Overton
Jan 21, 2016
<p>It's a fairly common issue: you load your WordPress page and get an error, "Cannot modify header information - headers already sent ...."</p> <p>This problem is almost certainly that your theme or a plugin is sending whitespace unintentionally. You can start by turning off your plugins and adding them back one at a time until the error reappears. (If it's happening with all plugins off, it's in the theme.) Then, hunt for a PHP file that has a ?&gt; at the end of the file with whitespace (a space, tab, hard return, etc) after it.</p> <p>A <a href="https://www.google.com/webhp?sourceid=chrome-instant&amp;ion=1&amp;espv=2&amp;ie=UTF-8#q=best%20practice%20closing%20php%20tag">Google search on the topic</a> has lots of good information (including those that would dissent from my opinion, which is "leave out the closing ?&gt;".) I think this <a href="http://hardcorewp.com/2013/always-omit-closing-php-tags-in-wordpress-plugins/">2013 article</a> is as good an explanation as any.</p> <p>This can happen on any PHP page, but I've run into it almost exclusively on WordPress sites simply due to the nature of how plugins and themes are loaded. It's not a WordPress problem, though, just PHP.</p> <p> </p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus