Different header images for pages? (11 posts)

  1. Shamis
    Posted 10 years ago #

    Does anyone know how to make my header image change depending on my page?

  2. bob58
    Posted 10 years ago #

    What do you want to do ? Depending on what ?

  3. Shamis
    Posted 10 years ago #

    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

  4. Kafkaesqui

    Posted 10 years ago #

    <?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; ?>


  5. Shamis
    Posted 10 years ago #

    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

  6. Kafkaesqui

    Posted 10 years ago #

    page_template.php? What theme are you using?

  7. gbarber
    Posted 10 years ago #

    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.


  8. volcaremos
    Posted 10 years ago #

    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)

  9. volcaremos
    Posted 10 years ago #

    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; ?>

  10. auxillary
    Posted 10 years ago #

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


  11. SileesWorkshop
    Posted 9 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.