Error:
Warning: Cannot modify header information - headers already sent by (output started at /home/ya3mblog/public_html/wp-login.php:59) in /home
Add this code in wp-config.php
on the first line:
ob_start();
error_reporting(0);
In my case happened because from the Wordpress Rest API in the functions I was ending the job by doing
echo json_encode($result);
instead of the simple:
return $result;
Changing that.. worked!
See How_do_I_solve_the_Headers_already_sent_warning_problem? > FAQ Troubleshooting « WordPress Codex
(This error) is usually because there are spaces, new lines, or other stuff before an opening
<?php
tag or after a closing?>
tag, typically in wp-config.php.
Open the file with a plain text editor (like Notepad or BBEdit) and clear out the white space. Check that the very first characters are <?php
and the very last characters are either NOT a PHP closing tag, or a closing tag ?>
with no blank lines or spaces after it. (FYI, a PHP file can run fine without the closing ?>
tag.)
When saving, be sure the file encoding is not UTF-8 BOM but plain UTF-8 or any without the BOM suffix.
And:
This could be true about some other file too, so please check the error message, as it will list the specific file name where the error occurred. Replacing the faulty file with one from your most recent backup or one from a fresh WordPress download is your best bet.
If the error message states:
Warning: Cannot modify header information - headers already sent by (output started at /path/blog/wp-config.php:34) in /path/blog/wp-login.php on line 42
, then the problem is at line #34 of wp-config.php, not line #42 of wp-login.php. In this scenario, line #42 of wp-login.php is the victim. It is being affected by the excess whitespace at line #34 of wp-config.php.If the error message states: Warning:
Cannot modify header information - headers already sent by (output started at /path/wp-admin/admin-header.php:8) in /path/wp-admin/post.php on line 569
, then the problem is at line #8 of admin-header.php, not line #569 of post.php. In this scenario, line #569 of post.php is the victim. It is being affected by the excess whitespace at line #8 of admin-header.php.
remove the excess blankspace /home/ya3mblog/public_html/wp-login.php in line 59.