Troubleshooting guide · wordpress · Published 2026-08-15 · 3 min read
WordPress and PHP "headers already sent" white-screen fix
Fix the PHP headers already sent warning in WordPress that causes blank pages, by locating the output that precedes the header call.
- ·What the warning means
- ·Find the stray output
- ·Prevent and confirm
The message "Cannot modify header information - headers already sent" appears in WordPress when PHP has already written some output before a header was due, and that earlier output blocks the header of the HTTP response. In its mild form it is a warning on screen; in its severe form, when the layout or timing breaks, it shows as a white screen. The cause is almost always a small, invisible piece of text emitted before PHP intended to send a header.
What the warning means
PHP must send headers such as Location: and the response's Set-Cookie before it sends the body. Once even one character of the body has been output, headers can no longer be written. When code tries to set a header after output has started, PHP emits the "headers already sent" warning and skips that header.
That skipped header is what breaks a site. A redirect that never fires, a session that cannot start, or an HTTP header missing its content type can each surface as a blank page or a broken flow rather than a clear error.
The stray output almost always comes from one of three places:
- A UTF-8 byte order mark at the start of a PHP file, which is invisible in an editor but writes bytes before PHP runs.
- Whitespace or a newline outside the opening and closing PHP tags, often in or after
wp-config.phpor a theme file. - A file that was edited and saved with extra blank lines, the classic source.
Find the stray output
The warning itself names the file and line where output started, so read the exact file and line first.
- Open the named file in a hex or raw view, because blank lines and a byte order mark are not visible in a normal editor. A BOM shows as
EF BB BFat the very start. - Remove any blank line or whitespace before the opening
<?phptag, and remove any line after the closing tag at the end of the file. In WordPress, common culprits arewp-config.phpand thefunctions.phpof your theme. - Check every file that is loaded at the start of a request, since the first file with stray output triggers the warning for whatever runs next.
- Deactivate plugins in turn if the output is not visibly in a core file, because a plugin can include a template or helper file with stray whitespace. See plugin causes error for an order that does not lock you out.
The reliable way to confirm the remedy is a text editor that shows invisible characters, or a byte-oriented tool, so you clear the exact whitespace the file actually contains.
Prevent and confirm
Confirm the fix by reloading the page and checking that the warning is gone and headers send normally. If a caching layer sat in front of the error, clear the page cache so you are testing the origin and not a stale copy.
Prevent a repeat: save PHP files with no byte order mark, with no blank line above the opening tag, and remove the trailing closing tag when a file is pure PHP, which eliminates the opportunity for a stray newline at the end. See white screen of death and PHP fatal error taking a site down for the related blank-page failures and their proof the change reached the origin.