Support » Fixing WordPress » Different header images for pages?

Viewing 10 replies - 1 through 10 (of 10 total)
  • What do you want to do ? Depending on what ?

    Depending on my page name 🙂

    When i click on page “contact” i want another picture…when i click on “about” page I want another header picture

    <?php if(is_page()) : ?>
    <img src="/images/header-page.jpg" />
    <?php elseif(is_page('this-page') : ?>
    <img src="/images/this-page.jpg" />
    <?php elseif(is_page('that-page') : ?>
    <img src="/images/header-that-page.jpg" />
    <?php else : ?>
    <img src="/images/header.jpg" />
    <?php endif; ?>

    Thank you Kafkaesqui, i will try this out today

    PS: Another quick question, does anyone know why do my pages dont show sidebar?

    I have tried adding get_sidebar in the end of page_template.php file…but it doesnt work

    page_template.php? What theme are you using?

    Cool tips. I managed to get date specific page headers working on my own though. Basically, throughout the year my page header will change for stuff like Valentines Day, New Years Eve, Christmas, etc. So if it’s not any of those days, it’s my static image and then on those specific dates, it’ll change to a different image. Oh what fun.

    The Code above submitted by Kafkaesqui seems to have missing brackets. Couls someone please supply corrections? I tried to adapt this script to work with different categories but even by adding extra brackets and removing error message only the first category display a banner image. Is the final else required for code to work?

    Thank you (non-PHP expert)

    The non-PHP expert has worked it out by himself, the category requires at least one post to work ( I presume it is the same for pages ) for reference here is the code:

    <?php if (in_category(‘2’) ): ?>
    <img src=”path/image2.jpg” alt=’Category Name’ />
    <?php elseif (in_category(‘3’) ): ?>
    <img src=”path/image3.jpg” alt=’Category Name’ />
    <?php elseif (in_category(‘4’) ): ?>
    <img src=”path/image4.jpg” alt=’Category Name’ />
    <?php else : ?>
    <img src=”path/otherimage.jpg” />
    <?php endif; ?>

    Wasn’t looking for this but … damn this looks neat. Maybe I can use this in the future!


    I can’t get this to work.
    where do you put this code?
    I’ve tried like this in the header.php, but it doesn’t work, it shows just empty headerspace:

    #header { background: url(<?php if (is_page('7') ): ?>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/tdvheader01.jpg" alt='Uitmarkt' />
    <?php elseif (is_page('8') ): ?>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg" alt='alt8' />
    <?php else : ?>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg" />
    <?php endif; ?>) no-repeat bottom center; }

    I replaced the original #header with this.
    Any tips?
    Thanks already

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Different header images for pages?’ is closed to new replies.