当我尝试激活主题或尝试保存帖子时,我收到此错误(我激活了wp-debug):
警告:无法修改标头信息 - 已经发送的标头(输出在/mnt/webv/b3/13/56920413/htdocs/WordPress_02/wp-content/themes/BackpackFamily/functions.php:58开始)/ mnt第197行/webv/b3/13/56920413/htdocs/WordPress_02/wp-admin/post.php
警告:无法修改标头信息 - 已经发送的标头(输出在/mnt/webv/b3/13/56920413/htdocs/WordPress_02/wp-content/themes/BackpackFamily/functions.php:58开始)/ mnt第1171行/webv/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 »' . '</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;
}
?>
感谢您的帮助!
答案 0 :(得分:0)
根据您的评论,通知会被放在functions.php
文件的最后一行上。
这让我相信你的文件可能在你的php标签(<?php
之前的外面(之前,之后或之间)有错误的换行符和/或空格?>
)
删除结尾?>
的结束php标记 - 现在是WordPress recommended code style省略关闭的php标记。
另外,请确保在打开<?php
代码之前没有杂散换行符。
侧面评论:
这是一个通知,不是一个真正的错误。如果你关闭了调试,这将是一个非问题,因为通知会被静音
但是...
感谢您,以便在WP_DEBUG
设置为true的情况下测试您的代码。这是确保代码在没有通知的情况下运行的唯一方法!
答案 1 :(得分:0)
我建议你也阅读提供的链接,这样你就可以了解这个错误。它也可以解决你的问题。
答案 2 :(得分:0)
我认为文件functions.php的最后一行有一些空格字符 你应该删除最后一个?&gt;在那个文件上。