Before you start telling me there are already 10000000 posts on this error, I know.
I am working on a wordpress plugin and am recieving the following error when submitting my edit pages:
Warning: Cannot modify header information - headers already sent by (output started at ***\wp-content\plugins\***\meta-class-load.php:1067) in ***\wp-includes\pluggable.php on line 934
What's different about this error is the line it references does not interface with the header, nor output content before. I have checked for whitespace surrounding php tags, and there is none :P
This is the contents (and surrounds) of line 1067:
$name = $field['id'];
$type = $field['type'];
$old = $this->get_meta($post->ID, $field); // THIS IS THE LINE
$new = isset($_POST[$name]) ? $_POST[$name] : ($field['multiple'] ? array() : '');
Any ideas or solutions would be helpful. Thanks!
Never output anything before sending the
HEADER
, if you do so you will not be able to send the header and it will throw an error !It's also a good practice to set
error_reporting(0)
on production server to make sure that no error gets shown beforeheader
No output can be sent before all headers are sent. One of the files listed in the error, or possibly a file included by one of those files, is outputting something. It could be something intentional, a stray bit of white space, a warning or an error message.
To prevent the error you can try calling either ob_clean(); or ob_end_clean(); to clear the output buffer right before your header call. ob_end_clean(); is almost always successful in these cases.
1067 is the line that outputs content. Line 934 is the one setting the header. I think you have them backwards.