Viewing 6 replies - 1 through 6 (of 6 total)
  • I believe that in_category expects a categroy-id to be an integer (if it is a string it will assume a categroy-slug) so loose the quotes around 955 and see if that works.

    Having said that, wouldn’t it work better with just CSS? The body element has a class .category-955 So you could do something like:

    .category-955 #omc-logo {
    background: url(‘logo-green.png’);
    }

    .category-10 #omc-logo {
    background: url(‘logo-blue.png’);
    }

    etc.

    are you aiming a single posts or at category archive pages?

    for category archive pages, try to use is_category(955) – you can also use the category name or slug; http://codex.wordpress.org/Function_Reference/is_category

    can you post a direct link to a page or post where this is not working?

    what is the result? – no image? – the wrong image? – ?

    Thread Starter rulethenation

    (@rulethenation)

    Im aiming for single posts and category pages, if you rollover your mouse over my menu, each category is a different color and each post under that category has that same color scheme, so im trying to make the logo match that

    i also tried taking out the quotes and it didnt work, ill have to try the CSS option when I have time,

    these are the archive page, and the a page in that category that should have a green logo, however my code so far has no worked

    http://dopefuse.com/exclusive/

    &

    http://dopefuse.com/5-winter-albums-of-2012-you-want-to-look-out-for/

    seems to work already for single posts – example ‘atman – december’
    (will only work if the post is direct in the category)

    to include the cat archives, generally this should work:

    <?php if ( is_single() && in_category( 955 ) || is_category( 955 ) ) $logo_image = 'dopefuselogotopgreen.png';
                          else $logo_image = 'dopefuselogotop.png';?>
    Thread Starter rulethenation

    (@rulethenation)

    Beautiful. Thank you sir.

    Very Good Mr Aclhymyth

    I will put the full code That I am running

    <?php if ( is_single() && in_category( 1 ) || is_category( 1 ) ) $logo_image = 'logo_cat1.png';
                          else $logo_image = 'logo_cat1.png';?>  
    
    <?php if ( is_single() && in_category( 6 ) || is_category( 6 ) ) $logo_image = 'logo_cat6.png';?>
    
    <a id="omc-logo" href="<?php echo home_url();?>"><img src="http://www.dientesblancos.com/muro/wp-content/themes/pinboard/<?php echo $logo_image;?>" alt="<?php bloginfo('name');?> logo" <?php if ($omc_logo_image === NULL) { echo('height="96"'); }?> /></a>

    Note that I removed else $logo_image = 'logo_cat1.png';?> for the cat 6 becouse the main logo of the site is logo_cat1.png in this example.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Need help with a code for a different logo for each category’ is closed to new replies.