WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] best way to have different header image for each page? (8 posts)

  1. jmyers1643
    Member
    Posted 4 years ago #

    right now i have my header image in the css - so the image is the same for each page

    what steps would i need to take in order to make the header change for each page/section

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    You'd need to move the header image out of the CSS and into the page markup within header.php. Then you'd need to create a series of conditional statement that would determine what image was used on what page.

  3. jmyers1643
    Member
    Posted 4 years ago #

    found this code somewhere during my search and got it to work with one page
    <div id="<?php if ( is_page(2) ) { echo 'alt2-header'; } else { echo 'header'; } ?>">

    how do i add multipule pages to the code

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    Ok - that's another approach.

    <div id="<?php if (is_page(2)) echo 'alt2-header';
    elseif (is_page(3)) echo 'alt3-header';
    elseif (is_page(4)) echo 'alt4-header';
    else echo 'header'; ?>">

    From 2.8, you can also do something similar using using body_class.

    <?php
    if(is_page(3))	$class = 'alt-3';
    elseif(is_page(4))	$class = 'alt-4';
    else $class='';
    }?>
    <body <?php if (function_exists('body_class')) body_class($class); ?>>
  5. jmyers1643
    Member
    Posted 4 years ago #

    gotcha i'll try it out, thanks

  6. jmyers1643
    Member
    Posted 4 years ago #

    this worked great - however firefox seems to be the only browser that will display it correctly ??

  7. esmi
    Forum Moderator
    Posted 4 years ago #

    That doesn't make any sense - unless something else within the theme/CSS is impacting on it.

    I've just published an article on a 3rd method of implementing different headers, if that's of any use.

    http://quirm.net/2009/08/07/changing-headers-with-wordpress-body_class/

  8. Warren
    Member
    Posted 4 years ago #

    Hi All,

    The best way to show a different header images on different pages is to use this plugin :

    http://wordpress.org/extend/plugins/dynamic-headers

    Its fab, you can set .swf, .png, .jpg header banners to any specific page you choose

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.