繁体   English   中英

获取wordpress错误:无法修改标题信息

[英]Getting wordpress error: Cannot modify header information

当我尝试激活主题或者当我尝试保存帖子时,我收到此错误(我激活了wp-debug):

警告:无法修改标头信息 - 已在/ mnt / webv /中发送的标头(输出从/mnt/webv/b3/13/56920413/htdocs/WordPress_02/wp-content/themes/BackpackFamily/functions.php:58开始)第197行的b3 / 13/56920413 / htdocs / WordPress_02 / wp-admin / post.php

警告:无法修改标头信息 - 已在/ mnt / webv /中发送的标头(输出从/mnt/webv/b3/13/56920413/htdocs/WordPress_02/wp-content/themes/BackpackFamily/functions.php:58开始)第1171行的b3 / 13/56920413 / htdocs / WordPress_02 / wp-includes / pluggable.php

这是我的functions.php的代码,我做错了什么?

<?php

// Navigation

    if ( function_exists('register_nav_menus') ) {
        register_nav_menus(array(
            'main-navi' => __( 'Hauptnavigation' )
        ));
    }

// Thumbnails

    if ( function_exists( 'add_theme_support' ) )
        add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 200, 200, true );


// Read more Link

   function new_excerpt_more($more) {
       global $post;
       return ' … </br><a href="'. get_permalink($post->ID) . '">' . 'Mehr lesen &raquo;' . '</a>';
   }
   add_filter('excerpt_more', 'new_excerpt_more');



// Sidebar

    function sl_sidebar() {
        $args = array(
            'id'            => 'default_sidebar', 
            'name'          => __( 'Sidebar Header', 'text_domain' ),
            'description'   => __( 'Sidebar Header', 'text_domain' ),
            'before_title'  => '<h3><a href="#">',
            'after_title'   => '</a></h3>',
            'before_widget' => '',
            'after_widget'  => '',
        );
        register_sidebar( $args );
    }

    add_action( 'widgets_init', 'sl_sidebar' );

// Search Button

    add_filter('get_search_form', 'new_search_button');
    function new_search_button($text) {
        $text = str_replace('value="Suche"', 'value="Suchen"', $text);
        return $text;
    }
?>

感谢帮助!

根据您的评论,通知将被抛出到functions.php文件的最后一行

这让我相信你的php文件( <?php?>之外 (之前,之后或之间)某处可能有文件中的杂散换行符和/或空格

删除最后关闭的php标签?> - 这是WordPress推荐的代码样式,现在省略关闭的php标签。

此外,请确保在打开<?php标记之前没有杂散换行符。

边评论:
这是一个通知,不是一个真正的错误。 如果您关闭了调试,那么这将是一个非问题,因为通知会被静音。
但...
荣誉给你与测试代码WP_DEBUG设置为true。 这是确保您的代码在没有通知的情况下运行的唯一方法!

我建议你也阅读提供的链接,这样你就可以了解这个错误。 它也可能也可以解决您的问题。

修复标题错误: https//stackoverflow.com/a/8028987/4205975

我认为在文件functions.php的最后一行有一些空格字符你应该删除该文件的最后一个?>。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM