Cannot modify header Error in WordPress

This is one of the most common issues that developers have been facing which to be true makes us binge eat (I know other people say having girl issues makes you do that, but then again those people have never coded in their life). I’m hoping to help everyone who has this bloody error once and for all. These simple set of steps have worked for me over and over again, and I am sure and hope it works for you guys. But even if the steps did not work then also don’t worry, I have also put a master cure for all WARNING message in wordpress and this has been done after many head-bangs against the keyboard.

Here we go. First off, you need to know WHERE the issue is coming from. Let’s use your error as an example

Warning: Cannot modify header information – headers already sent by (output started at /home/prodesigns/rajindiatravels.com/wp-content/themes/prodesigns_travel/custom/custom_functions.php:1) in /home/prdesigns/rajindiatravels.com/wp-includes/pluggable.php on line 876

Now, the BOLDED section is the culprit. Not pluggable.php so don’t worry about it. So, what you have to do is go into your FTP/Cpanel.

Step 1. Go into /wp-content/themes/prodesigns_travel/custom/custom_functions.php (or whatever the location is showing in the first set of parenthesis) Copy (CTRL-C) the entire document – no more, no less.

Step 2. Open your code editor (notepad++ or Dreamweaver) which ever you use and paste (CTRL-V) the entire document into that file. Go to the top of the file and make sure there is no extra space before <? php and at the end of the document make sure there is no extra space after ?>

Step 3. Save AS in Notepad. Rename the file to custom_functions.php (or the name of the file that you copied).

Step 4. Go into your FTP/File Manager, and upload the PHP file. It will probably ask you if you want to overwrite the file (because it already exists) – YES you do want to overwrite it .

Step 5. Refresh your Browser, and voilà the original error message *Should* go away, if its not gone then don’t hit your head or give up just now

wperror01wperror02

it might flash another error, instead of /wp-content/themes/prodesigns_travel/custom/custom_functions.php as the culprit, it may throw something random like /wp-content/plugins/someplugin/theplugin.php. So don’t worry just carry out the steps 1 to 5 on that file as well, but if you see that no spaces or any other characters are found in step 1 and 2 , but still the error persist then usually people will give up, but like I promised in the starting of the post, that I will give you a secret cheat over all the warnings.

// log php errors, prevent display to user, does not work if WP_DEBUG is true

@ini_set(‘error_reporting’, 4339 ); // moderate error reporting level, ignores notices

@ini_set(‘html_errors’, ‘Off’);  // startup errors off

@ini_set(‘display_errors’,’Off’); // disable public display of errors

@ini_set(‘log_errors’,’On’);  // enable php error logging

// path to server-writable log file, example shown, must be changed to a valid path for your server

@ini_set(‘error_log’,’/home/content/123456/logs/PHP_errors.log’);

 

Just copy this code and paste it on wp-config.php just below the line where it says

define( ‘WP_DEBUG’, false );

and this little cheat will help you disable any kind of warning on your website and I can’t promise that this will fix any plugin issue or code not working, but this small cheat on config file will stop them from appearing any kind of wanring on your website.

I sure hope this helps. but after trying all of the other help files with no luck, this has worked for me!

Leave a Reply

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

4 + eighteen =