警告:无法修改标头信息-标头已发送

时间:2012-03-26 作者:user1255049

我刚在尝试上传图像后收到此错误/警告,你知道这意味着什么吗?我能做些什么来修复它?

警告:无法修改标题信息-标题已由/home/achenn/public\\u html/wp content/themes/whskytngfxtrt/functions.php:14)在/home/achenn/public\\u html/wp includes/pluggable中发送。php在线866

Here\'s my site, live.

功能。php:

<?php

// sidebar functions

if(function_exists(\'register_sidebar\'))
{
    register_sidebar();
}


?>


<?php

// portfolio functions

    add_action(\'init\', \'create_portfolio\');
    function create_portfolio() {
        $portfolio_args = array(
            \'label\' => __(\'Portfolio\'),
            \'singular_label\' => __(\'Portfolio\'),
            \'public\' => true,
            \'show_ui\' => true,
            \'capability_type\' => \'post\',
            \'hierarchical\' => false,
            \'rewrite\' => true,
            \'supports\' => array(\'title\', \'editor\', \'thumbnail\')
        );
        register_post_type(\'portfolio\',$portfolio_args);
    }
?>

<?php

// custom input- portfolio backend

    add_action("admin_init", "add_portfolio");
    add_action(\'save_post\', \'update_website_url\');
    function add_portfolio(){
        add_meta_box("portfolio_details", "Portfolio Options", "portfolio_options", "portfolio", "normal", "low");
    }
    function portfolio_options(){
        global $post;
        $custom = get_post_custom($post->ID);
        $website_url = $custom["website_url"][0];
?>
    <div id="portfolio-options">
        <label>Website URL:</label><input name="website_url" value="<?php echo $website_url; ?>" />     
    </div><!--end portfolio-options-->   
<?php
    }
    function update_website_url(){
        global $post;
        update_post_meta($post->ID, "website_url", $_POST["website_url"]);
    }
?>

<?php 

// detail columns- portfolio backend

add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");
add_action("manage_posts_custom_column",  "portfolio_columns_display");

function portfolio_edit_columns($portfolio_columns){
    $portfolio_columns = array(
        "cb" => "<input type=\\"checkbox\\" />",
        "title" => "Project Title",
        "description" => "Description",
    );
    return $portfolio_columns;
}

function portfolio_columns_display($portfolio_columns){
    switch ($portfolio_columns)
    {
        case "description":
            the_excerpt();
            break;              
    }
}
?>
投资组合。php-

<?php
/*
Template Name: Portfolio
*/
?>
<?php get_header(); ?>
    <div id="content">
    <?php 
        $loop = new WP_Query(array(\'post_type\' => \'portfolio\', \'posts_per_page\' => 10)); 
    ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <?php   
        $custom = get_post_custom($post->ID);
        $screenshot_url = $custom["screenshot_url"][0];
        $website_url = $custom["website_url"][0];
    ?>
        <div id="portfolio-item">
        <h1><?php the_title(); ?></h1>
        <a href="<?=$website_url?>"><?php the_post_thumbnail(); ?> </a>
        <?php the_content(); ?>
    </div>
        <?php endwhile; ?>  
        </div><!-- #content -->
<?php get_footer(); ?>

1 个回复
最合适的回答,由SO网友:EAMann 整理而成

从外观上看,某些页面正在尝试加载functions.php 直接翻页。我不确定这是你的主题的另一部分,还是一个插件,或者其他一些自定义代码。但是第14行上的错误会触发第二个<?php 在中打开标记functions.php 文件

headers already sent 当您发送任何额外的空格、换行符或不应该发送的文本时,会触发错误。短期修复方法是删除额外的标记:

<?php // sidebar functions
if(function_exists(\'register_sidebar\')) {
    register_sidebar();
}

// portfolio functions
add_action(\'init\', \'create_portfolio\');
看看它有多紧凑?之间没有额外的空格?><?php 任何一个

不过,从长远来看,你需要缩小你正在做的事情的范围。你从哪里上传图像?为什么它试图重定向到functions.php 文件回答这些问题并修复导致问题的任何问题,以获得更持久的修复。

结束

相关推荐