Viewing 5 replies - 1 through 5 (of 5 total)
  • Can you be a little more verbose?

    Thread Starter staticmouse

    (@staticmouse)

    sorry. I noticed that there was a plug-in that would randomize your headers (jpeg, etc). Is there a way to have worpress display a different header depending on what categoryis clicked? For example, If i click on a category title “bears” the header for that section would be a picture of a bear. I hope that makes sense. I may have just confused myself.

    I don’t believe WP has the intrinsic ability to associate images with individual categories, nor is there a plugin to do so. Perhaps you can write something yourself and share with others who might like it?

    You can – and this code will probably appear mangled..

    <h1 id="header"
    class="<?php if(is_home()) echo('header1');
    elseif(is_category('Dogs') ) echo('header2');
    elseif(is_category('Cats') ) echo('header3');
    elseif(is_category('VanillaDietCoke') ) echo('header4');
    elseif(is_single()) echo('header5');
    elseif(is_page())echo('header6'); ?>"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>

    h1.header1 {
    background-image: url('http://www.tamba2.net/banner.jpg');
    background-repeat:no-repeat;
    height: 145px;
    }

    You need to define the hl.header2, h1.header3 etc

    Note that in there you can also have headers for a single page, headers for pages and the home header.

    If you want headers per page … I’m not sure but it’s something like
    elseif(is_page('Dogs') ) echo('header2');
    I think.

    Hey Podz:
    So I’ve kinda/sorta made slight modifcations to your code in order to work with my forthcoming site, but I’m a bit sqeamish to try it yet. Wanted you or someone to double-check and answer a question or two before I give it a go.

    So this is the code that I would put into my header.php file in the theme I’m using. I have multiple banners that I’d like to invoke, depending on the category or page…

    <div id=”header”
    class=”<?php if(is_home()) echo(‘header1’);
    elseif(is_category(‘Charts’) ) echo(‘header2’);
    elseif(is_category(‘News’) ) echo(‘header3’);
    elseif(is_category(‘Playlists’) ) echo(‘header4’);
    elseif(is_category(‘Reviews’) ) echo(‘header5’);
    elseif(is_category(‘Podcasts’) ) echo(‘header6’);
    elseif(is_page(‘radio-show’))echo(‘header7’);
    elseif(is_page(‘about’))echo(‘header8’);
    elseif(is_page(‘press’))echo(‘header9’);
    elseif(is_page(‘dj’))echo(‘header10’);
    elseif(is_page(‘contact’))echo(‘header11’);
    elseif(is_page(‘guestbook’))echo(‘header12’); ?>”>“><?php bloginfo(‘name’); ?>
    </div>

    At the moment, my style sheet has the header like this…

    #header {
    background: url(images/ul-banner.png) no-repeat;
    height: 145px;
    }

    So would I be able to get away with making something like…

    #header2 (and the code)

    Or do I need to do it another way? I’m intrigued by getting this all to work with a minimal amount of coding. Thanks in advance!

    Velanche

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Different headers for different categories?’ is closed to new replies.