Getting wordpress error: Cannot modify header information

Getting wordpress error: Cannot modify header information

当我尝试激活主题或尝试保存主题时出现此错误(我激活了 wp-debug)post:

Warning: Cannot modify header information - headers already sent by (output started at /mnt/webv/b3/13/56920413/htdocs/WordPress_02/wp-content/themes/BackpackFamily/functions.php:58) in /mnt/webv/b3/13/56920413/htdocs/WordPress_02/wp-admin/post.php on line 197

Warning: Cannot modify header information - headers already sent by (output started at /mnt/webv/b3/13/56920413/htdocs/WordPress_02/wp-content/themes/BackpackFamily/functions.php:58) in /mnt/webv/b3/13/56920413/htdocs/WordPress_02/wp-includes/pluggable.php on line 1171

那是我的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 recommended code style 现在省略结束 php 标记。

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

旁注:
这是一个通知,并不是真正的错误。如果您关闭了调试,这将不是问题,因为通知将被静音。
但是...
感谢您WP_DEBUG 设置为 true 来测试您的代码。这是确保您的代码在没有通知的情况下运行的唯一方法!

我建议您也阅读提供的 link,这样您就可以大致了解此错误。它也可能会解决您的问题。

修复 header 错误:https://whosebug.com/a/8028987/4205975

我认为文件的最后一行 functions.php 有一些 space 个字符 您应该删除该文件上的最后一个 ?>。