programing

헤더 정보를 수정할 수 없습니다. 헤더가 이미 전송되었습니다...Word Press 문제

css3 2023. 4. 5. 22:08

헤더 정보를 수정할 수 없습니다. 헤더가 이미 전송되었습니다...Word Press 문제

이 오류가 발생하고 있습니다. 이 문제를 어떻게 해결해야 할지 모르겠습니다.

헤더 정보를 수정할 수 없습니다. 헤더는 이미 에 의해 전송되었습니다(출력 시작은 /home/ben213/public_html/wp-content/temes/Bendagers/functions)./home/ben213/public_displays/wp-displays/pluggable에 있습니다.934행의 php

기능.php 파일의 9번째 행은 다음과 같습니다.

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

내 플러그에 꽂을 동안.php #934는

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;

저는 프로그래머가 아니기 때문에 이것을 이해하는 데 어려움을 겪고 있어요.뭐가 문제인 것 같아요?제발 도와주세요...

테마는 출력(텍스트)을 브라우저로 인쇄하는 것이지만, WordPress는 어떤 이유에서인지 전체 페이지가 렌더링되기 전에 해당 페이지에서 사용자를 (wp_redirect를 사용하여) 리다이렉트합니다.출력 인쇄를 시작하고 나서 리다이렉트 할 수 없습니다.그렇지 않으면 에러가 표시됩니다.그것이 Paul Grime이 그의 논평에서 말하고자 했던 것이다.

Ken White는 비슷한 문제가 있는 게시물을 언급하며 코멘트를 했다.저는 스크립트의 출력을 버퍼링함으로써 이 문제를 해결했습니다.

테마의functions.php파일(테마의 페이지가 로드될 때마다 포함됨)은 다음을 추가합니다.

//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();
}

이제 테마의 일부가 브라우저에 입력을 전송하기 시작하더라도 페이지가 완전히 로드될 때까지 PHP는 해당 텍스트를 전송하지 않으므로 WordPress는 필요에 따라 사용자 자신의 논리의 일부로 사용자를 리디렉션할 수 있습니다.

조건을 적용했거나 조건을 지정하지 않은 현재 페이지에서 다른 페이지로 리디렉션하려는 경우 이 코드를 사용하십시오.E.gs에는 A.php, B.php, B.php의 2페이지가 있으며, 현재 A.php에서는 버튼을 클릭하면 다른 페이지 B.php로 이동합니다.

   if(isset($_POST['save_btn']))
    {
        //write some of your code here, if necessary
        echo'<script> window.location="B.php"; </script> ';
     }

언급URL : https://stackoverflow.com/questions/7381661/cannot-modify-header-information-headers-already-sent-by-wordpress-issue