• I have tried to change one of my pages to have a new header image.

    To do this I replaced <?php get_header(); ?> with <?php include (‘header2.php’); ?>

    The new header displays correctly at the top, however now a second old header is displaying after the footer. If I put <?php get_header(); ?> right after <?php include (‘header2.php’); ?> at the top of the page, the bottom header is removed, but now I obviously have two headers.

    The reason I am using a second header is to change a div and remove a search function in the “old” header code.

    Is there another way to go about making this change or editing the <?php get_header(); ?> Any help would be welcome.

Viewing 3 replies - 16 through 18 (of 18 total)
  • Yes, if you basically want to have one page use a completely different header file (e.g. header2.php or something) you should be able to do it with conditional tags like I showed above.

    <?php
      if (is_page("your-page-name-or-id")) {
      echo '<?php include ('header2.php'); ?>';
      }  else {
       echo '<?php get_header(); ?>';
      }
    ?>

    That *should* cause it to get your header for a given page and the default header for the rest of your pages (I think).

    Remember that the <?php get_header(); ?> call is usually in more than one php file in your theme. Since your blog page is not the home page you may have to edit page.php rather than index.php. Also keep in mind that if you upgrade or change your theme you’ll lose your mods, so keep backups.

    This is straight out of the documentation:

    Suppose you want to include a file called header2.php. Just insert the following line in your template where you want that file’s information to appear.

    <?php include( TEMPLATEPATH . '/header2.php' ); ?>

    So to make that conditional….

    <?php
      if (is_page("your-page-name-or-id")) {
      echo '<?php include( TEMPLATEPATH . '/header2.php' ); ?>';
      }  else {
       echo '<?php get_header(); ?>';
      }
    ?>

    Should work.

    Thread Starter skibybadoowap

    (@skibybadoowap)

    Adding just
    <?php include( TEMPLATEPATH . '/header2.php' ); ?>
    To the top of my blog.php page is working!

    However it produces an error “Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘,’ or ‘;’ in /path-name…”

    The code that is not working is the

    Update: I figured out what was causing the issue, I had this at the top of my blog page:

    <?php include( TEMPLATEPATH . '/header2.php' ); ?>
    <title>Blog</title>

    So although it was displaying the error instead of the second header, when I removed the title the second header was back.

    I’m not sure the conditional will work correctly without making something like is_blog(). I’d rather just hard code whatever I need to in blog.php to get it to work because the blog.php page is being tweaked in many other ways.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘<?php get_header(); ?> Displaying at the bottom’ is closed to new replies.