How to display different logos according to post category
-
Dear community
I am trying to have the headers of my wp blog display a different logo according to a post category. I managed to write the code that allows each category page to display its own logo, but all my posts are always displaying the fallback logo instead of the category one.
Link to the blog: https://bit.ly/Xa5dkN
I have many categories on this blog and this is the code I wrote to have the different logos displayed on the category pages:
<?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('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; ?>
What is the right code to make my posts display the right logo according to its respective category?
Thank you very much for your help
Viewing 9 replies - 1 through 9 (of 9 total)
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.