• Hello everyone.
    I’m having this problem of header already sent. I already saw everything about that here but nothing worked. I know that the problem is on the line 1 of functions.php, but I checked and looked for blank spaces before and after the <?php , ?> but nothing was there. Can someone help me please!! The login page now is blank because of that!

    PHP Warning: Cannot modify header information – headers already sent by (output started at /home/itcloset/public_html/blog/wp-content/themes/stylismo/functions.php:1) in /home/itcloset/public_html/blog/wp-includes/pluggable.php on line 1121

    The line 1 and the rest of the function.php is:

    <?php
    if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'sidebar', 'before_widget' => '', 'after_widget' => '<br clear="all" /><br />', 'before_title' => '<div id="titulo-sidebar">', 'after_title' => '</div><br />', ));
    register_sidebar(array( 'name' => 'blog', 'before_widget' => '', 'after_widget' => '<br clear="all" /><br />', 'before_title' => '<div id="titulo-sidebar">', 'after_title' => '</div><br />', ));
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator t-p

    (@t-p)

    Thread Starter julymorais

    (@julymorais)

    I already saw that, and tried everything they said, but there isn’t any space before or after the <?php and ?>

    It could also be from closing and immediately opening a new php tag…

    this will cause issues:

    <?php echo 'something here...'; ?> <?php echo 'something else here...'; ?>

    which should be

    <?php 
    
    echo 'something here...';
    
    echo 'something else here...';
    
    ?>

    Thread Starter julymorais

    (@julymorais)

    I don’t know. I’m not an expert so I can’t read those things. Functions is like this:

    <?php
    if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'sidebar', 'before_widget' => '', 'after_widget' => '<br clear="all" /><br />', 'before_title' => '<div id="titulo-sidebar">', 'after_title' => '</div><br />', ));
    register_sidebar(array( 'name' => 'blog', 'before_widget' => '', 'after_widget' => '<br clear="all" /><br />', 'before_title' => '<div id="titulo-sidebar">', 'after_title' => '</div><br />', ));
    register_sidebar(array( 'name' => 'publicidade', 'before_widget' => '<div id="publicidade">', 'after_widget' => '</div>', 'before_title' => '', 'after_title' => '', ));
    
    if ( function_exists( 'add_theme_support' ) ) :
    add_theme_support( 'post-thumbnails' );
    add_filter('widget_text', 'do_shortcode');
    
    endif;
    
    function post_pagination($pages = '', $range = 4)
    {
         $showitems = ($range * 2)+1;  
    
         global $paged;
         if(empty($paged)) $paged = 1;
    
         if($pages == '')
         {
             global $wp_query;
             $pages = $wp_query->max_num_pages;
             if(!$pages)
             {
                 $pages = 1;
             }
         }   
    
         if(1 != $pages)
         {
             echo "<div id='pagenavi'><font style='float:left; margin: 5px 10px 0 0;'>Página $paged de $pages</font>";
             if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."' class='current'>Anterior</a>";
             if($paged > 4 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>1</a> <span class='current'>...</span>";
    
             for ($i=1; $i <= $pages; $i++)
             {
                 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
                 {
                     echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
                 }
             }
    
             if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<span class='current'>...</span> <a href='".get_pagenum_link($pages)."'>$pages</a>";
             if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."' class='current'>Próxima</a>";
             echo "</div>\n";
         }
    } 
    
    if ( ! function_exists( 'parent_comment' ) ) :
    function parent_comment( $comment, $args, $depth ) {
        $GLOBALS['comment'] = $comment;
        switch ( $comment->comment_type ) :
            case '' :
        ?>
            <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>"> <?php echo get_avatar( $comment, 74, $default = 'http://itcloset.com.br/wp-content/uploads/2014/07/avatar.png' ); ?>
    <div class="comment">
    <span class="commentname"> <b><?php comment_author_link(); ?></b><br>
    <?php comment_date('j \d\e F \d\e Y') ?> às <?php comment_time('H:i'); ?> <?php edit_comment_link(' (Editar)','',''); ?>
    </span>
    
                <?php comment_text() ?> 
    
                <?php if ( $comment->comment_approved == '0' ) : ?>
                    <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
                <?php endif; ?>  
    
                <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>     
    
    </div>
            </li>  
    
    <hr />
    
        <?php
                break;
            case 'pingback'  :
            case 'trackback' :
        ?>
        <li class="post pingback">
            <p><?php _e( 'Pingback:' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)' ), ' ' ); ?></p>  
    
        <?php
                break;
        endswitch;
    }
    endif;
    ?>

    Could also be a plugin that is modifying the headers. I would disable all plugins and confirm that it is caused by your theme.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Problem: PHP Warning: Cannot modify header information – headers already sent by’ is closed to new replies.