WordPress Warning Cannot Modify Header Information Headers Already Sent
How to Fix It
If you have ever opened your WordPress website and been greeted by the message Warning: Cannot modify header information – headers already sent, it can be alarming. Your website may still load, but something is clearly wrong.
The good news is that this error is usually caused by a relatively small PHP formatting or coding problem. In many cases, you can identify the offending file and fix the issue without rebuilding your website.
Understanding what WordPress is trying to tell you makes the problem much easier to solve. In this guide, we will explain what the warning means, why it happens, how to find the exact source, and the safest ways to fix it.
Whether you are a complete WordPress beginner or someone who occasionally edits theme files, these steps will help you troubleshoot the problem methodically.

The Core Basics
Before fixing the warning, it helps to understand what WordPress and PHP mean by headers.
When someone visits your website, the server sends information to the browser before sending the visible webpage. These HTTP headers can contain instructions relating to cookies, redirects, caching, authentication, content types, and other server responses.
PHP must send these headers before any actual page content is sent to the browser.
The problem occurs when PHP starts sending visible output first and then WordPress or a plugin attempts to send an HTTP header afterward.
That is when you may see:
Warning: Cannot modify header information – headers already sent
The second part of the message is particularly useful because WordPress usually tells you which file and line generated the unwanted output.
Common causes include:
* Extra spaces before ``
* Accidental characters in a PHP file
* UTF-8 BOM characters
* A plugin producing unexpected output
* A theme file containing unwanted whitespace
* Incorrect PHP code
* A corrupted or improperly edited file
The warning does not necessarily mean WordPress itself is broken. Often, one small file is responsible.
💡 WP Fix It
Co Recommendation: If you’re dealing with the wordpress warning cannot modify header information headers already sent, a fast, secure WordPress host can make troubleshooting, backups, file access, and implementing the solution much smoother. Get Hostinger WordPress Hosting here.
Step-by-Step Guide to Fix the Warning
1. Read the Complete Error Message
Don’t immediately start changing files.
First, carefully read the warning displayed by WordPress. Look for wording similar to:
`Warning: Cannot modify header information – headers already sent by (output started at /path/to/file.php:25)`
The important information is usually the filename and line number.
For example, if WordPress says output started at:
`/wp-content/themes/mytheme/functions.php:25`
you should investigate that file first.
The line number may not always be the exact location of the problem, but it gives you an excellent starting point.
2. Check for Extra Spaces Before the PHP Opening Tag
One of the simplest causes is whitespace before the opening PHP tag.
A PHP file should generally begin like this:
“`php
“`
There should not be random spaces, blank lines, or other characters before it.
For example, this can cause trouble:
“`php
“`
If the file is being interpreted in a way that sends those characters to the browser, PHP may consider output to have already started.
Open the affected file and remove unnecessary whitespace before `
“`
That seemingly harmless space can sometimes trigger the headers warning.
For PHP-only files, one useful practice is to **omit the closing `?>` tag altogether**.
Instead of:
“`php
“`
use:
“`php
// PHP code
“`
This reduces the possibility of accidentally adding whitespace after the PHP code.
4. Look for Unexpected Characters
Sometimes the problem isn’t an obvious space.
A PHP file can contain accidental characters introduced while editing, copying, or uploading the file.
Check for:
* Blank lines
* Invisible characters
* Random punctuation
* HTML outside PHP tags
* Text accidentally pasted into the file
* Encoding-related characters
This is especially important if you recently edited `functions.php`, a plugin file, or another PHP file.
5. Consider the UTF-8 BOM Problem
A less obvious cause is the UTF-8 Byte Order Mark, commonly called a BOM.
Some text editors save PHP files with a BOM at the beginning. Although the characters may not be visible in a normal editor, they can be interpreted as output before PHP sends its headers.
If the warning appeared immediately after editing a PHP file, encoding is worth checking.
Save the file as UTF-8 without BOM if your editor provides that option.
6. Check Recently Installed or Updated Plugins
If the problem started after installing or updating a plugin, that plugin deserves attention.
A plugin that generates unexpected output can cause headers to be sent too early.
If you can still access WordPress:
1. Go to Plugins.
2. Identify plugins installed or updated around the time the problem began.
3. Temporarily deactivate the suspected plugin.
4. Refresh the website.
5. Check whether the warning disappears.
If the warning vanishes, you have a strong indication that the plugin is responsible.
Do not leave important security, backup, or performance plugins disabled permanently just to hide the warning. Identify the underlying problem first.
7. Check Your Theme’s functions.php File
The WordPress theme’s `functions.php` file is another frequent location for this problem.
This file can contain custom snippets, tracking code, redirects, filters, and other PHP instructions. A tiny formatting mistake can therefore create the warning.
If you recently added custom PHP code, temporarily remove or comment out the new code and test the site again.
Always make a backup before editing the file.
If you’re using the WordPress Theme File Editor, be particularly careful. A mistake in `functions.php` can sometimes cause a site-wide PHP error.
Using your hosting file manager or a secure FTP connection can give you another way to access the file if WordPress becomes inaccessible.
8. Use a Backup Before Making Changes
Never treat a live WordPress website as a place to experiment blindly.
Before changing PHP files:
* Create a complete backup.
* Record what you are changing.
* Change one thing at a time.
* Test the website after each change.
If the change makes things worse, you can restore the previous version.
This simple habit can save considerable time.
9. Don’t Simply Hide the Warning
You may find advice telling you to turn off PHP warnings so visitors cannot see the message.
That can make the warning disappear from view, but it does not necessarily fix the underlying problem.
There is a difference between hiding an error and correcting it.
If a plugin or theme is attempting to send headers after output has started, that underlying conflict may still cause redirects, cookies, login behavior, caching, or other functions to behave incorrectly.
Fix the source wherever possible.
Best Practices and Pro Tips
The easiest way to deal with WordPress PHP errors is to prevent unnecessary problems in the first place.
Keep WordPress, your themes, and plugins updated, but avoid updating everything blindly on a busy production website. A backup and a quick compatibility check can prevent unpleasant surprises.
When editing PHP files, use a proper code editor rather than a basic word processor. Save PHP files using an appropriate UTF-8 encoding and avoid unnecessary closing PHP tags.
It is also wise to maintain regular website backups and use reliable WordPress hosting with dependable server performance and security features.
If your website is important to your business, consider testing major changes on a staging copy before applying them to the live site.
Finally, don’t ignore recurring PHP warnings. A website that appears to work today may still have an underlying configuration or coding issue that becomes more serious after a future update.
Common Mistakes to Avoid
Beginners often make the problem worse by rushing the repair.
Avoid these mistakes:
* Editing several files at once: You won’t know which change fixed or caused the problem.
* Ignoring the filename in the warning: The error message often gives you the most useful clue.
* Deleting code without a backup: Always keep a copy of the original file.
* Only hiding the warning: Suppressing an error isn’t the same as fixing it.
* Using untrusted code snippets: Poorly written PHP can introduce new problems.
Take a methodical approach instead. Identify the source, back up the file, make one change, and test.
Conclusion: Fix the Problem at Its Source
The wordpress warning cannot modify header information headers already sent message looks technical, but the underlying cause is often surprisingly simple.
In many cases, the problem comes from unwanted whitespace, accidental output, an encoding issue, or a plugin or theme generating output before WordPress has finished sending its HTTP headers.
Start by reading the complete error message. Identify the file and line number, inspect the affected code, and work backward from the point where output began.
Most importantly, create a backup before modifying PHP files.
At WP Fix It Co, our goal is to make WordPress troubleshooting easier to understand. If you encounter another WordPress warning or PHP problem, don’t panic. Follow the evidence in the error message, make controlled changes, and test carefully.
A systematic approach will solve many WordPress problems faster than trial and error.