[英]Warning: Cannot modify header information - headers already sent by in wordpress
unable to add contents in pages like about us ,courses,contact us..while adding the content error is displaying无法在关于我们、课程、联系我们等页面添加内容..同时显示添加内容错误
Warning: Cannot modify header information - headers already sent by (output started at /home/phptraining/public_html/wp-content/themes/health-center-lite/functions.php:95) in /home/phptraining/public_html/wp-admin/post.php on line 235
警告:无法修改标题信息 - 标题已由 /home/phptraining/public_html/wp- 中的(输出开始于 /home/phptraining/public_html/wp-content/themes/health-center-lite/functions.php:95)发送admin/post.php 在第 235 行
and和
Warning: Cannot modify header information - headers already sent by (output started at /home/phptraining/public_html/wp-content/themes/health-center-lite/functions.php:95) in /home/phptraining/public_html/wp-includes/pluggable.php on line 1196
警告:无法修改标题信息 - 标题已由 /home/phptraining/public_html/wp- 中的(输出开始于 /home/phptraining/public_html/wp-content/themes/health-center-lite/functions.php:95)发送包括/pluggable.php 在线 1196
functions.php函数.php
<?php /**Includes reqired resources here**/
define('WEBRITI_TEMPLATE_DIR_URI',get_template_directory_uri());
define('WEBRITI_TEMPLATE_DIR',get_template_directory());
define('WEBRITI_THEME_FUNCTIONS_PATH',WEBRITI_TEMPLATE_DIR.'/functions');
define('WEBRITI_THEME_OPTIONS_PATH',WEBRITI_TEMPLATE_DIR_URI.'/functions/theme_options');
require( WEBRITI_THEME_FUNCTIONS_PATH . '/menu/default_menu_walker.php' ); // for Default Menus
require( WEBRITI_THEME_FUNCTIONS_PATH . '/menu/webriti_nav_walker.php' ); // for Custom Menus
require( WEBRITI_THEME_FUNCTIONS_PATH . '/commentbox/comment-function.php' ); //for comments
require( WEBRITI_THEME_FUNCTIONS_PATH . '/widget/custom-sidebar.php' ); //for widget register
//content width
if ( ! isset( $content_width ) ) $content_width = 900;
//wp title tag starts here
function hc_head( $title, $sep )
{ global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( _e( 'Page', 'helth' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'hc_head', 10,2 );
add_action( 'after_setup_theme', 'hc_setup' );
function hc_setup()
{ // Load text domain for translation-ready
load_theme_textdomain( 'health', WEBRITI_THEME_FUNCTIONS_PATH . '/lang' );
add_theme_support( 'post-thumbnails' ); //supports featured image
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary', __( 'Primary Menu', 'health' ) );
// theme support
$args = array('default-color' => '000000',);
add_theme_support( 'custom-background', $args );
add_theme_support( 'automatic-feed-links');
require_once('theme_setup_data.php');
require( WEBRITI_THEME_FUNCTIONS_PATH . '/theme_options/option_pannel.php' ); // for Custom Menus
// setup admin pannel defual data for index page
$health_center_lite_theme=theme_data_setup();
function hc_custom_excerpt_length( $length ) { return 50; }
add_filter( 'excerpt_length', 'hc_custom_excerpt_length', 999 );
function hc_new_excerpt_more( $more ) { return '';}
add_filter('excerpt_more', 'hc_new_excerpt_more');
$current_theme_options = get_option('hc_lite_options'); // get existing option data
if($current_theme_options)
{ $hc_lite_theme_options = array_merge($health_center_lite_theme, $current_theme_options);
update_option('hc_lite_options',$hc_lite_theme_options);
}
else
{ add_option('hc_lite_options',$health_center_lite_theme); }
}
/******** health center js and cs *********/
function hc_scripts()
{ // Theme Css
wp_enqueue_style('health-responsive', WEBRITI_TEMPLATE_DIR_URI . '/css/media-responsive.css');
wp_enqueue_style('health-font', WEBRITI_TEMPLATE_DIR_URI . '/css/font/font.css');
wp_enqueue_style('health-bootstrap', WEBRITI_TEMPLATE_DIR_URI . '/css/bootstrap.css');
wp_enqueue_style('health-font-awesome', WEBRITI_TEMPLATE_DIR_URI . '/css/font-awesome-4.0.3/css/font-awesome.min.css');
wp_enqueue_script('health-menu', WEBRITI_TEMPLATE_DIR_URI .'/js/menu/menu.js',array('jquery'));
wp_enqueue_script('health-bootstrap_min', WEBRITI_TEMPLATE_DIR_URI .'/js/bootstrap.min.js');
}
add_action('wp_enqueue_scripts', 'hc_scripts');
if ( is_singular() ){ wp_enqueue_script( "comment-reply" ); }
// Read more tag to formatting in blog page
function hc_content_more($more)
{ global $post;
return ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"hc_blog_btn\">Read More<i class='fa fa-long-arrow-right'></i></a>";
}
add_filter( 'the_content_more_link', 'hc_content_more' );
?>
<?php
/**
* Register Widget Area.
*
*/
function wpgyan_widgets_init() {
register_sidebar( array(
'name' => 'Header Sidebar',
'id' => 'header_sidebar',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'wpgyan_widgets_init' );
?>
This has nothing to do with functions.php sending headers. 这与functions.php发送标头无关。 Rather, it has to do with output having started (in the functions file) before headers are sent (by other WordPress scripts).
相反,它与在发送标头(由其他WordPress脚本发送)之前开始的输出(在功能文件中)有关。 What you'll see, if you look on
line 95
, is the following: 如果您看
line 95
,将会看到以下内容:
?>
<?php
That blank line between the closing and opening PHP tags is the cause of the error. 关闭和打开PHP标记之间的空白行是导致错误的原因。 Instead, you should get rid of both of those tags, so that your code becomes:
相反,您应该摆脱这两个标记,以便您的代码成为:
add_filter( 'the_content_more_link', 'hc_content_more' );
/**
* Register Widget Area.
*
*/
function wpgyan_widgets_init() {
While you're at it, also delete the last line of your functions.php file (the closing ?>
PHP tag). 在使用它的同时,还要删除functions.php文件的最后一行(结尾的
?>
PHP标记)。 It's unnecessary here. 这里没有必要。
This error is not specific to wordpress. 此错误不是特定于wordpress的。 This is a standard error of PHP.
这是PHP的标准错误。 This problem is occurring because you are trying to modify headers after an output is generated in that page like php echo or some html is rendered.
发生此问题的原因是,您试图在该页面中生成输出(如php echo或呈现某些html)后修改标头。
I hope this helps you. 我希望这可以帮助你。
i've the same error in my WordPress.我的 WordPress 也有同样的错误。
I am installing the ElementsKIT plugin to make a modification in my header, but when enabling the module I get the following error:我正在安装 ElementsKIT 插件以在我的标题中进行修改,但是在启用模块时出现以下错误:
Warning: Cannot modify header information - headers already sent by (output started at /home/customer/www/staging6.seoalive.com/public_html/wp-admin/includes/template.php:2528) in /home/customer/www/staging6.seoalive.com/public_html/wp-includes/pluggable.php on line 1340警告:无法修改标题信息 - 标题已由 /home/customer/www/ 中的(输出开始于 /home/customer/www/staging6.seoalive.com/public_html/wp-admin/includes/template.php:2528)发送staging6.seoalive.com/public_html/wp-includes/pluggable.php 在线 1340
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.