开发者

Cannot modify header information - headers already sent by… Wordpress Issue

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:

<?php if(function_exists('register_sidebar'))register_sidebar();?>

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: $loca开发者_如何学编程tion", 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...


I'll give 99.9% this trouble comes up because of undesirable whitespace(s) somewhere before the first "<?" and after the last "?>" in a php script. Editing saving a file in different encoding can add such whitespace too (because of BOM). So it's not always depends on your attentivness. Use Notepad2 or something to edit code and better try to use in-built on-line theme editor in the admin console. Try to find and eliminate all undesidrable whitespaces in every theme's php file and resave those files.


In my pluggable.php find function wp_redirec and in that replace

header("Location: $location", true, $status);

with

echo "<meta http-equiv='refresh' content='0;url=$location' />";


I know nothing about wordpress, but I know something about http... Maybe this can help.

The error happens because you try to change a header field, although the headers have already been sent. The headers are (automatically) sent when the actual page content are written for the first time.

(The http-headers are part of the http-protocol that sends html-pages, not a part of the html file. Stuff like status codes (404,etc) encodings, etc is sent in the headers. So in order to start writing the actual page, the headers must be written first.)

It looks like the theme (?) is used too soon, or that the "redirect" plugin is activated too late...

Try to move the "register_sidebar" until after you have checked if to do a redirect.

EDIT:

From reading you other questions, I can tell that You need to learn how to program, or use another tool. Find one or two books and give it some time. PHP is a rather mashed up language, so its not really ideal to learn how to program in, but since you seems to need it, well, there you are.

Good luck.


Here's what solved the problem for me! In 'function.php' line 9' which probably looks like

 ?>

 <?php

remove the spaces so that it looks like:

 ?>
 <?php
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜