[英]Getting wordpress error: Cannot modify header information
I'm getting this error (I activated wp-debug) when I try to activate a theme or when I try to save a post: 当我尝试激活主题或者当我尝试保存帖子时,我收到此错误(我激活了wp-debug):
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
警告:无法修改标头信息 - 已在/ 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
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
警告:无法修改标头信息 - 已在/ 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
That's the code of my functions.php, what did I do wrong? 这是我的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;
}
?>
Thanks for help! 感谢帮助!
Per your comment, the notice is being thrown on the last line of your functions.php
file. 根据您的评论,通知将被抛出到
functions.php
文件的最后一行 。
Which causes me to believe that you likely have stray line-feeds and /or spaces in your file somewhere outside (before, after, or between) your php tags ( <?php
and ?>
) 这让我相信你的php文件(
<?php
和?>
) 之外 (之前,之后或之间)某处可能有文件中的杂散换行符和/或空格
Remove the closing php tag at the end ?>
- it's the WordPress recommended code style now to omit the closing php tag. 删除最后关闭的php标签
?>
- 这是WordPress推荐的代码样式,现在省略关闭的php标签。
Also, be sure there's no stray line feeds before the opening <?php
tag. 此外,请确保在打开
<?php
标记之前没有杂散换行符。
Side-comment: 边评论:
This is a NOTICE, not really an error. 这是一个通知,不是一个真正的错误。 If you had debug turned off, it would be a non-issue because notices would be silenced.
如果您关闭了调试,那么这将是一个非问题,因为通知会被静音。
BUT... 但...
Kudos to you for testing your code with WP_DEBUG
set to true. 荣誉给你与测试代码
WP_DEBUG
设置为true。 This is the only way to be sure your code runs without notices! 这是确保您的代码在没有通知的情况下运行的唯一方法!
I recommend you read the link provided too, so you get an understanding of this error in general. 我建议你也阅读提供的链接,这样你就可以了解这个错误。 It might also fix your problem too.
它也可能也可以解决您的问题。
Fix header error: https://stackoverflow.com/a/8028987/4205975 修复标题错误: https : //stackoverflow.com/a/8028987/4205975
我认为在文件functions.php的最后一行有一些空格字符你应该删除该文件的最后一个?>。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.