Header per category / page / home
-
Goal: To display a different header image depending on if what is being display is Home or a Category or a Page.
This page – https://codex.www.ads-software.com/Template_Tags/get_the_category#Show_Category_Images – has this code:
<?php foreach((get_the_category()) as $cat)
{ echo '<img src="https://example.com/images/' . $cat->cat_ID . '.jpg"
alt="' . $cat->cat_name . '" />'; } ?>I have no idea at all how I would write the If / Else parts.
If (Home) then (header-1)
Else
If (Cat) then (header-for-that-cat)
Else
If (Page) then (header-2)Is this possible ? If it is, would anyone be so kind to write it for me ? (If it is doable then when I get it working I will write it up for Codex)
- The topic ‘Header per category / page / home’ is closed to new replies.