• Resolved mrmccarrin

    (@mrmccarrin)


    Hi,

    My website is https://lawyerdev.meganrmccarrin.com/practice-areas/

    and I am trying to create a custom header for my Front Page template. I have created a php doc and named it custom-header.php,however, when I go to add any code to that php doc, I get the following error,

    Warning: Cannot modify header information – headers already sent by (output started at /homepages/43/d459884280/htdocs/wordpress-4.0/wordpress/wp-content/themes/shape/inc/custom-header.php:13) in /homepages/43/d459884280/htdocs/wordpress-4.0/wordpress/wp-includes/pluggable.php on line 1173

    I cannot understand how to fix this? Can someone please help?

    Thank you!

Viewing 15 replies - 1 through 15 (of 25 total)
  • Thread Starter mrmccarrin

    (@mrmccarrin)

    I apologize, I just realized that I meant to title this Custom Header. Plus, I wanted to add that any changes I try to make to my custom header, changes the look of the back end of my website.

    Thank you.

    Megan

    Can you post the contents of custom-header.php to Pastebin and post the link here?

    Thread Starter mrmccarrin

    (@mrmccarrin)

    My custom-header.php is currently empty because anytime I put my code in, I get the error above.

    This is what I was attempting to put in:

    </script>”>

    or, I think you can view it here:

    Thank you.

    Thread Starter mrmccarrin

    (@mrmccarrin)

    Thread Starter mrmccarrin

    (@mrmccarrin)

    Thread Starter mrmccarrin

    (@mrmccarrin)

    I apologize, I do not know why pastebin is not working. Does this work:

    <!DOCTYPE html>
    
    <!--[if IE 8]>
    <html id="ie8" <?php language_attributes(); ?>>
    <![endif]-->
    <!--[if !(IE 8) ]><!-->
    <html <?php language_attributes(); ?>>
    <!--<![endif]-->
    
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <meta name="viewport" content="width=device-width" />
    <title><?php
    /*
    * Print the <title> tag based on what is being viewed.
    */
    global $page, $paged;
    
    wp_title( '|', true, 'right' );
    
    // Add the blog name.
    bloginfo( 'name' );
    
    // Add the blog description for the home/front page.
    $site_description = get_bloginfo( 'description', 'display' );
    if ( $site_description && ( is_home() || is_front_page() ) )
    echo " | $site_description";
    
    // Add a page number if necessary:
    if ( $paged >= 2 || $page >= 2 )
    echo ' | ' . sprintf( __( 'Page %s', 'shape' ), max( $paged, $page ) );
    
    ?></title>
    <link rel="profile" href="https://gmpg.org/xfn/11" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
    <![endif]-->
    <?php wp_head(); ?>
    </head>
    
    <body <?php body_class(); ?>>
       <nav role="navigation" class="site-navigation main-navigation">
         <h1 class="assistive-text"><?php _e( 'Menu', 'shape' ); ?></h1>
         <div class="assistive-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'shape' ); ?>"><?php _e( 'Skip to content', 'shape' ); ?></a></div>
    <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
    </nav><!-- .site-navigation .main-navigation -->
    <div id="page" class="hfeed site">
    
         <header id="masthead" class="site-header" role="banner">
             <div>
    
         <h1 class="site-title"><a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
         <h2 class="site-description"><?php bloginfo( 'description' ); ?>Lawyer Website</h2>
    </div>
    
         <div style="padding-top:45px; margin-left: 180px;">
    <a href="https://lawyerdev.meganrmccarrin.com/wp-content/uploads/2014/10/Lawyer-Logo.jpeg"><img src="https://lawyerdev.meganrmccarrin.com/wp-content/uploads/2014/10/Lawyer-Logo-300x118.jpeg" alt="Lawyer Logo" width="300" height="118" class="alignnone size-medium wp-image-38" /></a></div>
    <div style="float: right; margin-right: 50px; top: 5px; margin-top: -75px;  font-size: 2.6rem; color: black;  font-weight: 200; font-family: Merriweather;">STOP BY OR CALL: (718)-369-6666</div><br>
         </header><!-- #masthead .site-header -->
    <div id="main" class="site-main"></div>

    The issue is that the opening <?php tag must be the very first thing in a PHP file. There can be no spaces, tabs, nothing, before the tag. It should work if you try something like this:

    <?php //empty ?>
    <!DOCTYPE html>
    
    <!--[if IE 8]>
    <html id="ie8" <?php language_attributes(); ?>>
    <![endif]-->
    ...
    Thread Starter mrmccarrin

    (@mrmccarrin)

    Thank you, but I am continuing to get the same error.

    Currently, this is my code:

    <?php //empty ?>
    <!DOCTYPE html>
    
    <!--[if IE 8]>
    <html id="ie8" <?php language_attributes(); ?>>
    <![endif]-->
    <!--[if !(IE 8) ]><!-->
    <html <?php language_attributes(); ?>>
    <!--<![endif]-->
    
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <meta name="viewport" content="width=device-width" />
    <title><?php
    /*
    * Print the <title> tag based on what is being viewed.
    */
    global $page, $paged;
    
    wp_title( '|', true, 'right' );
    
    // Add the blog name.
    bloginfo( 'name' );
    
    // Add the blog description for the home/front page.
    $site_description = get_bloginfo( 'description', 'display' );
    if ( $site_description && ( is_home() || is_front_page() ) )
    echo " | $site_description";
    
    // Add a page number if necessary:
    if ( $paged >= 2 || $page >= 2 )
    echo ' | ' . sprintf( __( 'Page %s', 'shape' ), max( $paged, $page ) );
    
    ?></title>
    <link rel="profile" href="https://gmpg.org/xfn/11" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
    <![endif]-->
    <?php wp_head(); ?>
    </head>
    
    <body <?php body_class(); ?>>
       <nav role="navigation" class="site-navigation main-navigation">
         <h1 class="assistive-text"><?php _e( 'Menu', 'shape' ); ?></h1>
         <div class="assistive-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'shape' ); ?>"><?php _e( 'Skip to content', 'shape' ); ?></a></div>
    <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
    </nav><!-- .site-navigation .main-navigation -->
    <div id="page" class="hfeed site">
    
         <header id="masthead" class="site-header" role="banner">
             <div>
    
         <h1 class="site-title"><a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
         <h2 class="site-description"><?php bloginfo( 'description' ); ?>Lawyer Website</h2>
    </div>
    
         <div style="padding-top:45px; margin-left: 180px;">
    <a href="https://lawyerdev.meganrmccarrin.com/wp-content/uploads/2014/10/Lawyer-Logo.jpeg"><img src="https://lawyerdev.meganrmccarrin.com/wp-content/uploads/2014/10/Lawyer-Logo-300x118.jpeg" alt="Lawyer Logo" width="300" height="118" class="alignnone size-medium wp-image-38" /></a></div>
    <div style="float: right; margin-right: 50px; top: 5px; margin-top: -75px;  font-size: 2.6rem; color: black;  font-weight: 200; font-family: Merriweather;">STOP BY OR CALL: (718)-369-6666</div><br>
         </header><!-- #masthead .site-header -->
    <div id="main" class="site-main"></div>

    Do you have another suggestion?

    Thank you for your time,

    Megan

    For some reason I can’t reproduce your error anymore. How are you calling this file?

    Thread Starter mrmccarrin

    (@mrmccarrin)

    I do not have it called anywhere right now and currently it is producing a double header, which if I refresh a bunch produces the error.

    Thread Starter mrmccarrin

    (@mrmccarrin)

    I now recieve this error only:

    Warning: Cannot modify header information - headers already sent by (output started at /homepages/43/d459884280/htdocs/wordpress-4.0/wordpress/wp-content/themes/shape/inc/custom-header.php:5) in /homepages/43/d459884280/htdocs/wordpress-4.0/wordpress/wp-includes/pluggable.php on line 1173

    There are a couple of different ways this error can show up, and I’m trying to pin down the reason so I can help you better. If your file did not have this error, what PHP code are you using to call in this file?

    Thread Starter mrmccarrin

    (@mrmccarrin)

    Thank you for your help. To not get the error, I have nothing in the custum-header.pho file. That us the only way I have avoided the error. Does that answer your question?

    No, I mean how does this file get included in your front page template? Does your front page template call get_header()? Do you use include() or require()?

    Thread Starter mrmccarrin

    (@mrmccarrin)

    My front page template uses get_header()?

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Customer Header’ is closed to new replies.