Need to find out how to fix the "Cannot modify header information" error?
Here is a common and frustrating WordPress error that can interrupt the execution of your website by displaying an error like:
Warning: Can not modify header information
What is worse is that this error persists, listing the paths to important files on your server, which is a potential security risk.
But do not worry ! This is one of the easiest errors to fix and in this tutorial I will show you how to fix it as well as how to hide error messages on the frontend of your blog.
But before, if you have never installed WordPress discover How to Install a WordPress Blog in 7 Steps et How to search, install and activate a WordPress theme on your blog
Then back to why we are here.
Probably a header problem?
Of course, this error may seem daunting and make you think there is a problem on the file " header.php Or something similar, but it's more of a space created in one of your files (usually before PHP's opening tags). Sometimes these spaces are added unintentionally or automatically and need to be adjusted.
Discover How to fix the "file_get_contents" error on a WordPress blog
The error manifests itself when there is:
- Blank lines at the top or bottom of a document
- Too many spaces before, between or after the beginning of the opening and closing php tags " <?php " and " ?> »
- There are too many unnecessary spaces or blank lines in a specific part of a document
In order to fix the spacing issue, you first need to know where the spacing is. Fortunately, the error message lets you know which file and which line is affected. Keep in mind that you may see this sequence multiple times on the page which means there are multiple files that need to be fixed.
Here is the basic structure to look for to decipher the broken file:
Warning: Can not modify header information - headers already sent by (output started at /path/to/file/broken-file.php:#) in /path/to/file/affected-file.php on line #
The first file listed as
/path/to/file/broken-file.php
would be the one that needs to be corrected and the "#" character will be replaced by a number that will tell you which line to correct.
The second file written in this structure as
/path/to/file/affected-file.php
is the file that can not work properly because the first file is broken. The "#" symbol at the end in a real situation would be a number that indicates the line in the document that would be affected and therefore will not work.
How to fix the "500 Internal Server" error on WordPress ? Discover by consulting this link.
Here is another example of what this error might look like on your website:
Warning: Can not modify header information - headers already sent by (output started at /home/name/your-site/wp-content/themes/your-theme/custom-functions.php:1) in / home / name / your- site / wp-includes / pluggable.php on line 876
In this example, “name” will be the username of your cPanel or hosting account and “your-site” will be replaced with the name of the folder where your website is stored. The error you will see will certainly be different, but it should give you an idea of what to do.
Learn by consulting this article How to fix an 504 error on your WordPress website
In this example, the file " custom-functions.php 'Within the' your theme 'folder is the document that needs to be fixed and the error is on one line.
Fortunately, this problem is not very difficult to resolve, although it can seem daunting at first.
Some solutions:
There are two main ways you can correct this error. If you are stuck during this fix, you are free to contact us, we are willing to help you.
We also invite you to consult How to fix the "Can not write to disk" error on WordPress
Here is a list of solutions that you can put into practice
Fix # 1: Download a fresh copy
When you read the error message and determine that the offending file is a part of the WordPress core or is otherwise an inherent file of a plugin or theme, there is a quick fix available.
If this file is in a plugin or theme, you can uninstall it and reinstall it.
Discover How to remove string v = xxx from WordPress URLs
If you'd rather not do this or if a WordPress core file is affected, you can download a fresh copy and extract the ZIP archive to your computer. Locate the offending file on your website and replace the existing one on your server with the new copy.
You can do this with the help of FTP, SSH or directly through the cPanel.
Fix # 2: Modification of the file in question
Once you have identified the file in question, you can download a copy of it by FTP or SSH, or you can edit it directly in the cPanel.
Erase any blank lines or extra spaces at the beginning and end of the document. Also, make sure there is no space before, between or after the " <?php At the beginning of the file. The same goes for the end tag " ?> ».
If the last line of the document does not end with a "?>" Tag, make sure there is no space after the last line.
Save the file and transfer it to your website, overwriting the original file.
Disable error reporting
Now if you have fixed the problem, nothing will stop these errors from coming back and being visible to everyone who visits your website, including hackers.
There is nothing worse that can happen to your website because revealing the file paths on your server could give hackers the exact information they need to target your website or blog.
You can turn off front-end error reporting and enable a private log with WP_DEBUG
. Check out the changes we recommend for your "wp-config.php" file.
Discover also some premium WordPress plugins
You can use other WordPress plugins to give a modern appearance and to optimize the handling of your blog or website.
We offer you here some premium WordPress plugins that will help you do that.
1. WooCommerce Currency Switcher
The WooCommerce Currency Switcher plugin allows you to change currency and get the rates converted in real time (WooCommerce installation required beforehand). You can use currency aggregators to get converted rates either by Yahoo, Google, AppSpot aggregators, either manually.
WooCommerce Currency Switcher is available as a widget and works in any space provided (shortcode available -> [woocs]). On the public interface, "Currency Switcher" can be presented in 5 different ways to discover.
Download | Demo | Web hosting
2. Ultimate Membership Pro
Ultimate Membership Pro is a great WordPress Plugin subscription and content restriction. It allows users to be managed according to their package (free or paid) by creating exclusive access levels.
It will therefore be possible to protect all the content of your website, or just part of it. It will be for example a course, a lesson, a page, a product, a category, an image, etc ...
Its main features include: content protection, multiple levels of access, support for multiple payment gateways -PayPal, Authorize.net, Stripe, 2CheckOut, Bank Transfer-, partial content protection, and much more again…
Download | Demo | Web hosting
3. W8 Contact Form
W8 Contact Form is one of the plugins of Contact form the most popular on WordPress. It offers a lot of features such as submission to multiple recipients, support for animations, unlimited form creation, different styles, and a wide variety of additional customization options.
In addition, it gives your website or blog a professional system to make it easier to get in touch with your customers. You will be able to customize all of your forms according to your needs and your tastes.
Download | Demo | Web hosting
Other recommended resources
We also invite you to consult the resources below to go further in the grip and control of your website and blog.
- 10 WordPress plugins to create an affiliate program
- 10 WordPress plugins to create tabs on your blog
- 9 WordPress plugins to create a quiz on your website
- 10 premium WordPress plugins from Booking and Booking
Conclusion
Here ! That's it for this tutorial. We hope this will help you fix the "Cannot modify header information" error on WordPress. In eThis tutorial has been useful to you, we invite you to the share on your favorite social network.
However, you will also be able to consult our resources, if you need more elements to carry out your projects of creation of Internet sites, by consulting our guide on the WordPress blog creation.
Tell us about your Comments and suggestions in the dedicated section.
...
Hello,
I have a similar problem on my blog, but looks different, I spent hours on English forums without doing anything good!
I therefore allow myself to ask you to know if you could help me, I have already posted a topic on the wordpress forum but no one is helping me ...
I have had this message for some time:
Warning: Use of undefined constant wp_82869517_ - assumed 'wp_82869517_' (this will throw an Error in a future version of PHP) in /home/bymaryb2/public_html/wp-config.php on line 68
Warning: Cannot modify header information - headers already sent by (output started at /home/bymaryb2/public_html/wp-config.php:68) in /home/bymaryb2/public_html/wp-includes/functions.php on line 6221
If I understood correctly, it is WP-INCLUDES which is in question? except that I am told not to touch it, as a result I am stuck ...
Thank you for your help !
Marie B
for me
I had added a line (in the config.php file), but nothing else
with this error I removed the line that I had added, but still this same error;
headers already sent by (output started at /var/www/sdb/e/0/xxxxxx/wp-config.php:1) …… ..
the error was simply resolved (after seeing this answer on a forum)
in notepad ++
it was necessary to encode wp-config.php in UTF-8 without Bom
(the default option was UTF-8 with Bom)
and then it was good
if it can help ..
Thank you
Hi,
I tried removing the spaces from the wp-config.php file but that didn't solve the problem.
Warning: Cannot modify header information - headers already sent by (output started at /home/……/wp-config.php:1) in /home/……/wp-includes/pluggable.php on line 1251
Warning: Cannot modify header information - headers already sent by (output started at /home/………./wp-config.php:1) in /home/………/wp-includes/pluggable.php on line 1254
The front end is always accessible.
Can you help me please?
The thank you box
Lan
Hi,
Can you try disabling all other plugins to see if the error persists?
Hi Rosalie,
I have exactly this error. How did you solve it?
Hello, having very little to manipulate WP, I am simply trying to integrate a page developed by myself in the admin.
Problem, I have this error that persists:
Warning: Cannot modify header information - headers already sent by (output started at /home/andennebe/domains/andenne.be/public_html/db2/wp-includes/formatting.php:5523) in / home / andennebe / domains / andenne. be / public_html / db2 / wp-content / plugins / map-generator / map-generator.php on line 34
I redownloaded the wp-includes / formatting.php file, I tried to remove all unnecessary spaces, to compact the code as much as possible but nothing helped… The error is located at line 5523 at the level of the javascript ..
Here is my code that is in the wp-content / plugins / map-generator folder that generated this error.
add_action ('admin_menu', 'add_links_menu');
function add_links_menu () {
add_menu_page ('wp / admin', 'GPX card', 'manage_options', 'index.php', 'my_admin_menu', 'dashicons-admin-site', 6);
}
function my_admin_menu () {
header ('location: index.php');
}
When I replace the header ('location') by an include it generates another error which is the following ...:
Fatal error: Can not redeclare _wp_menu_output () (previously declared in /home/andennebe/domains/andenne.be/public_html/db2/wp-admin/menu-header.php:68) in /home/andennebe/domains/andenne.be /public_html/db2/wp-admin/menu-header.php on line 259
I hope you can help me. Thanks in advance