1
votes

I'm trying to get a header image to display differently on certain category pages. For example, a image of a football player will be displayed on all the posts with the category of football.

This needs to be displayed on archive pages too, so I used the conditional tag

is_category('football') 

for example, this worked fine. Though it doesn't show the header image on the actual post page itself. Is there a way I can make this work somehow? Maybe another conditional tag in there somewhere?

Any help would be greatly appreciated.

1
at what files you are using this code? - swapnesh
it's in the file of header.php - rowefx

1 Answers

1
votes

Actually in WordPress you can use a conditional tags in many ways. In your question you mentioned you want to check if it's in the category/archive page and you know that how to do it but in a comment you mentioned you want to check if a post belongs to a category and in this case it could be on a single post page.

To check in the single post page you can use

if(is_single() && in_category('football'))

You may check these links in_category, is_object_in_term and is_single.