• I would like to have a specific header image for each category. I’ve searched the plugins and came up empty. anyone know of one or how to change the code to accomplish this? Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You’ll need to use conditional tags.

    http://codex.wordpress.org/Conditional_Tags#A_Category_Page

    Thread Starter dotman

    (@dotman)

    Thank you jeremy. Could you give me an example of the modified code for say two categories? I’m assuming this would be going in the header template. Thanks again.

    <?php if ( is_category(5) ) { ;?>
    <div id="headercat5">
    <?php } elseif ( is_category(6) ){ ;?>
    <dif id="headercat6">
    <?php } else { ;?>
    <div id="defaultheader">
    <?php } ;?>
    other stuff
    </div>

    Then just add the new ids to your style.css with the new background image.

    Thread Starter dotman

    (@dotman)

    Great, thank you, I’ll see if I can make it work. Are these tags also available for pages as well? Thanks again.

    Yes on that same link just scroll up a little for the page conditional tags.

    I found this post when looking for how to insert an image on the page (not changing the header), depending on the category. I ended up reading about conditions and came up with this:

    <?php if ( is_category(Baseball) ) { ;?>
    <?
    echo ‘<img src=”baseball image location here” width=”100″ height=”100″>’;
    ?>
    <?php } elseif ( is_category(Football) ){ ;?>
    <?
    echo ‘<img src=”football image location here” width=”100″ height=”100″>’;
    ?>
    <?php } elseif ( is_category(dance_team) ){ ;?>
    <?
    echo ‘<img src=”/dance teamimage location here” width=”100″ height=”100″ align=”left”>’;
    ?>
    <?php } else { ;?>

    <?php } ;?>

    The only trouble I had was one category named “Dance Team”. It didn’t like the space, so I used the category slug “dance_team” instead.

    Maybe this will help someone else.

    hi

    I’m trying to figure out how to have a simple header with just an image per category contained in it.. i thought i found the answer here.. but it doesnt seem to work

    http://www.femalepleasure.org/multitest/betabang/?cat=5

    i obviously also implemented the div(s) in my css but it wouldnt show

    I don’t see what i did wrong.. can someone help please?
    it would be such a relief !
    thanks !

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Different header image (not random) for each category?’ is closed to new replies.