WordPress Error: Cannot modify header information – pluggable.php

I finished up some code on Friday and left for the weekend. Didn’t look at the site, didn’t look at the code, didn’t look at any of the commits. First thing Monday morning I’m told the site is broken. It’s a WordPress site, so a blank screen means any number of awful things have happened.

After a quick look at my debug file (generated by using this debug code) I saw this.

PHP Warning:  Cannot modify header information - headers already 
sent by (output started at .../.../functions.php:1) 
in ../../wp-includes/pluggable.php on line 1179

So that at least narrows it down to the guilty file and guilty line.

Opening functions.php I didn’t see anything too suspicious. No broken code, no missing semicolons, PHP tags, nothing. Line 1, line 1. Hmmm.

I did a quick look in the WordPress support forums and it seemed unanimous that there was an extra space somewheres.

Taking a look at the repo on GitHub I found the jerk space. It was riiiiight before the opening PHP tag.



// instead of this


You got it, that small change was enough to bring down everything. Just goes to show that you need to be careful when copying code from around the web. Never know what small spaces might pop up.

Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
M Shafique Qadri
M Shafique Qadri
6 years ago

Add this at first line of wp-config.php:

John Hartley is a Director of Product Engineering at Beam Dental in Columbus, OH. With 7+ years of leadership experience he has worked in startups, agencies, and began his career as a freelance Front End Developer. Always looking to iterate, this blog is a place for him to share his knowledge as well as hone his craft, challenge assumptions, and build a strong base of leadership and management knowledge. Connect with him on LinkedIn

Would love your thoughts, please comment.x