Support » Fixing WordPress » How to display different logos according to post category

Viewing 9 replies - 1 through 9 (of 9 total)
  • I take it your theme has correctly named header files for each category? (i.e. header-home.php, header-ambiente.php, etc.)

    I created those Andrew. And now the category pages correctly display their respective logos. Yet post pages of those categories display only the fallback ( else ) version.

    I need every post to display the logo of it’s respective category as well. I hope it’s clear.

    Thank you

    Michael

    (@alchymyth)

    Forum Moderator

    for posts, try to use:

    is_single() && in_category()

    and add it with a logic OR to the if’s;

    example:

    elseif ( is_category('animali') || is_single() && in_category('animali') ) :
      get_header('animali');

    Hi alchymyth thank you. I tried it but it didnt work.

    Let me add the whole code with the link to a post in the animali category.

    <?php
    if ( is_home() ) :
      get_header('home');
    elseif ( is_category('ambiente') ) :
      get_header('ambiente');
    elseif ( is_category('green-news') ) :
      get_header('ambiente');
    elseif ( is_category('clima') ) :
      get_header('ambiente');
    elseif ( is_category('natura') ) :
      get_header('ambiente');
    elseif ( is_category('energie-rinnovabili') ) :
      get_header('ambiente');
    elseif ( is_category('vivere-a-basso-impatto') ) :
      get_header('ambiente');
    elseif ( is_category('inquinamento') ) :
      get_header('ambiente');
    elseif ( is_category('animali') ) :
      get_header('animali');
    elseif ( is_category('cani') ) :
      get_header('animali');
    elseif ( is_category('gatti') ) :
      get_header('animali');
    elseif ( is_category('animali') || is_single() && in_category('animali') ) :
      get_header('animali');
    elseif ( is_category('sport') ) :
      get_header('sport');
    elseif ( is_category('calcio') ) :
      get_header('sport');
    elseif ( is_category('formula-uno') ) :
      get_header('sport');
    
    elseif ( is_category('salute') ) :
      get_header('salute');
    elseif ( is_category('alimentazione') ) :
      get_header('salute');
    elseif ( is_category('psicologia') ) :
      get_header('salute');
    elseif ( is_category('fitness') ) :
      get_header('salute');
    elseif ( is_category('sessualita') ) :
      get_header('salute');
    elseif ( is_category('medicina') ) :
      get_header('salute');
    elseif ( is_category('attualita') ) :
      get_header('attualita');
    elseif ( is_category('rassegna-stampa') ) :
      get_header('attualita');
    elseif ( is_category('cronaca') ) :
      get_header('attualita');
    elseif ( is_category('politica') ) :
      get_header('attualita');
    elseif ( is_category('scienza-e-tecnologia') ) :
      get_header('attualita');
    elseif ( is_category('videogiochi') ) :
      get_header('videogiochi');
    else :
      get_header('home');
    endif;
    ?>

    link: http://bit.ly/XBBSz5

    Thank you for your support

    Andrea

    Oh actually I just had an idea that fixed the issue. I love it when this happens. This is the actual line the worked in my case:

    elseif ( is_single() && in_category('cani') ) :
      get_header('animali');

    Now I will duplicate and edit this line for each category of the blog.

    Thanks a lot!

    New problem came up related to the original issue.
    Im using Dynamic Widgets to display different widgets according to the category of the blog. Since I edited the header.php file the dynamic widget stopped functioning.

    Any takes on this one? Your help would be much appreciated.

    Thank you

    Michael

    (@alchymyth)

    Forum Moderator

    Since I edited the header.php file the dynamic widget stopped functioning.

    what is the effect?
    i.e. what exactly is different from what you intended?
    which widget is showing or not showing in which category or post?

    do all your header files contain the came code (apart from the logo section) ?

    Basically the plugin Dyanmic Widget is not functioning properly anymore.
    If I select show on checked and then say I want Picture with Cat on the category dedicated to Cats, the image doesnt show. The plugin is not working anymore, while before it did.

    I dont know what to do…. maybe I should try another plugin to get different sidebars. Any reccos?

    Thank you

    Without seeing the before and after of your header.php, I can only offer a guess– but since plugins frequently need hooks in the header to successfully do things, I’d speculate that when you edited the header, you might have accidentally disabled a hook.

    Any chance we might be able to see your header.php file?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to display different logos according to post category’ is closed to new replies.