WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the code below to add a logo in the header of certain pages and I'm wodering if there a way to add the logo(sublogo.jpg) to certain categories as well as "page-one", "page-two" and so on?

    <div id="header-logo" onclick="location.href='<?php bloginfo('url'); ?>'" style="cursor: pointer;" >
    <?php if (is_page(array('page-one', 'page-two', 'page-three','page-four'))) $logo_image = 'subLogo.jpg';
    else $logo_image = 'mainLogo.jpg';?>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/<?php echo $logo_image;?>" alt="<?php bloginfo('name'); ?>" />
    </div>

Thanks,

share|improve this question
up vote 2 down vote accepted

extend this line:

<?php if (is_page(array('page-one', 'page-two', 'page-three','page-four'))) $logo_image = 'subLogo.jpg';

with

|| is_category(array('cat-1', 'cat-2'))

so you get, for example:

<?php if (is_page(array('page-one', 'page-two', 'page-three','page-four')) || is_category(array('cat-1', 'cat-2')) ) $logo_image = 'subLogo.jpg';

http://codex.wordpress.org/Function_Reference/is_category

share|improve this answer
    
Thanks Michael, that's what I was looking for! – Nsokyi Jul 11 '11 at 13:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.