Wednesday, July 18, 2018
php - Cannot modify header information - headers already sent by... WordPress Issue
Answer
Answer
I'm encountering this error. and I have no idea dealing with this.
Cannot modify header information - headers already sent by (output
started at
/home/ben213/public_html/wp-content/themes/Bendaggers/functions.php:9)
in /home/ben213/public_html/wp-includes/pluggable.php on line 934
my Functions.php file line # 9 is:
while my pluggable.php # 934 is
function wp_redirect($location, $status = 302) {
global $is_IIS;
$location = apply_filters('wp_redirect', $location, $status);
$status = apply_filters('wp_redirect_status', $status, $location);
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$location = wp_sanitize_redirect($location);
if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location", true, $status);}
endif;
I'm having a hard time figuring this out since im not a programmer. what seems to be wrong?
kindly help me please...
Answer
Your theme is printing output (text) to the browser, but then for some reason WordPress is redirecting the user (with wp_redirect) away from that page before the whole page is rendered. You can't start printing output and then redirect, or you'll get the error you see. That's what Paul Grime was getting at in his comment.
Ken White commented with a reference to a post with a similar problem. I've fixed this in my own experience by buffering the output of the script.
In your theme's functions.php file (which gets included every time your theme's pages load), put the following:
//allow redirection, even if my theme starts to send output to the browser
add_action('init', 'do_output_buffer');
function do_output_buffer() {
ob_start();
}
Now, even if part of your theme starts to send input to the browser, PHP won't send that text until the page is fully loaded, which allows WordPress to redirect users, if necessary, as part of its own logic.
plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV
In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...
-
When the left part is an object instance, you use -> . Otherwise, you use :: . This means that -> is mostly used to access instance m...
-
i've started to create my website, but now i have few doubts. I've searched, that MySqli object oriented is good to use beca...
-
I've been asked to update some Excel 2003 macros, but the VBA projects are password protected, and it seems there's a lack of docume...
No comments:
Post a Comment