WordPress.org

Ready to get started?Download WordPress

Forums

Cannot modify header information - headers already sent (2 posts)

  1. pucklitaay
    Member
    Posted 2 years ago #

    To add the sidebar in my twentyeleven theme I've added functions.php + single.php files to my twentyeleven-child theme. But now it gives the following error:

    Warning: Cannot modify header information - headers already sent by (output started at /home2/voiceact/public_html/oop/wp-content/themes/twentyeleven-child/functions.php:2) in /home2/voiceact/public_html/oop/wp-includes/pluggable.php on line 881

    My functions.php in the child theme:

    <?php
    function remove_twentyeleven_body_classes() {
        remove_filter( 'body_class', 'twentyeleven_body_classes' );
    }
    add_action( 'after_setup_theme', 'remove_twentyeleven_body_classes' );
    ?>

    My single.php in the child theme:

    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    
    get_header(); ?>
    
    		<div id="primary">
    			<div id="content" role="main">
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<nav id="nav-single">
    						<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
    						<span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">&larr;</span> Previous', 'twentyeleven' ) ); ?></span>
    						<span class="nav-next"><?php next_post_link( '%link', __( 'Next <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></span>
    					</nav><!-- #nav-single -->
    
    					<?php get_template_part( 'content', 'single' ); ?>
    
    					<?php comments_template( '', true ); ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    			</div><!-- #content -->
    		</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  2. Doodlebee
    Member
    Posted 2 years ago #

    Delete he whitespace after the last ?> in your functions.php file.

    in fact, just delete the last ?> at the end of the file.

Topic Closed

This topic has been closed to new replies.

About this Topic