Support » Fixing WordPress » change header in single.php based on a term? (twentyeleven)

  • I have a child theme of twenty eleven and I’d like to be able to change the header image on single.php when it displays certain content. Basically I have a custom post type that makes a gallery, and each item in the gallery going to it’s own page. But I have 3 different galleries and of course everything goes into the single-posttype.php file. His is all done by a plugin so I can’t change it. I’ve been able to work out a way to change some of the content displayed by using taxonomy. So I have galleries for cats, dogs and rabbits and I’ve used <?php if (has_term( 'dogs', 'gallery-term' )) { ?> to change bits of the page according to which gallery it is.

    So far so good. But can I use the same trick with terms to change the header image depending on if the post is a member of dogs, cats or rabbits? And if that is possible, could I also tell it to get the featured image from a specific page? Because each gallery starts as a normal static page with a load of thumbnails to link to the gallery item. So if possible I’d like to be able to test for the term dogs and load up the featured image from the page dogs inside single.php!

    I hope that made some sense! As you can tell, I’m not entirely sure what I’m doing and I don’t write php so I’ve been using trial and error so far.

  • The topic ‘change header in single.php based on a term? (twentyeleven)’ is closed to new replies.