5/5 - (1 vote)

Are you dealing with the error “Cannot Modify Header Information – Headers Already Sent By” on the WordPress site? If yes, don’t miss our blog. We have provided you with some efficient solutions to help you tackle this error. Now, let’s check them out.

Why did your website get the error “Cannot Modify Header Information – Headers Already Sent By”?

The “Cannot Modify Header Information – Headers Already Sent By” error occurs in PHP when the web server tries to send HTTP headers, but some content has already been sent to the browser before the headers. Headers must be sent before any other content, including whitespace or any HTML tags, otherwise, the headers cannot be modified.

This error also comes to your website due to the following reasons:

  • Outputting data before calling the header() function.
  • Including files that contain whitespace or other content before calling the header() function.
  • Outputting error messages or notices before calling the header() function.
  • Using a UTF-8 encoded file with a byte-order mark (BOM) at the beginning, which is interpreted as content by the server and prevents headers from being sent.

Cannot Modify Header Information 1

 

To fix this error, make sure that any content is outputted after the header() function has been called. In today’s blog, we will give you detailed introductions to help you remove this error.

How to handle the error “Cannot Modify Header Information – Headers Already Sent By”?

In order to handle this error, you can try one of the following solutions

Method 1: Checking the problem file in Plugin/ Theme Editor

First of all, you need to find the file and the code line that cause this error. For instance:

Warning: Cannot modify header information – headers already sent by (output started at /home/public_html/wp-content/themes/twentytwentyone/functions.php:#) in /home/public_html/wp-includes/file-example.php on line 1

In our error example,  the error appears in the functions.php file of the Twenty Twenty-One theme and in line 1.

So, in order to eliminate it, you need to log in to your WordPress admin dashboard first. After that, go to Appearance -> Theme File Editor -> Theme Functions.

Cannot Modify Header Information 1

Now, all you need to do is check and ensure that there is no whitespace before the <?php tag. In case, it appears any whitespace before it, then you need to get rid of the whitespace, then don’t forget to click on the “Update File” button at the bottom of the page to save your changes.

Now, let’s reload your website and check if the error is gone.

Similarly, you can do the same process with the editor of your WordPress site by navigating to Plugins > Plugin editor.

However, sometimes, the error may appear due to a file in your WordPress plugin directory. In this case, you need to Delete and then install the plugin again. Then, the error will be handled.

Method 2: Editing the problem file by using FTP/ SFTP

In case the error ” Cannot Modify Header Information – Headers Already Sent By ” is caused by the file. But, unluckily you are not able to access directly in WordPress Themes or plugin editors.

Hence, it is a great way for you to access the error file via FTP/SFTP. You should note that there will be diverse approaches to the corrupted file, which rely on the type of FTP Client you are utilizing.

Once the file is opened, let’s locate the code line coming with the error.  Then, check the whitespace and remove it, don’t forget to save the changes and open the FTP/SFTP client.

After that, you can go back to your WordPress to check the result.

Cannot Modify Header Information 4

Wrap up

Hopefully, this blog gives you some effective solutions to handle your problem. In case, your error still doesn’t appear, please leave a comment below. We will give you another solution to help you.

Besides that, our blog provides you with several beautiful, free WordPress Themes. If you want to change your website’s appearance, don’t miss our website.

Leave a Reply

Your email address will not be published. Required fields are marked *

Summer Sale Get 50% OFF for your purchase on today! Coupon code: SUMMER2024 Redeem Now
Summer Sale Get 50% OFF for your purchase on today! Coupon code: SUMMER2024 Redeem Now