Need help – proper format conditionals for category specific header images?
I’m a php and wordpress newbie struggling to write a conditional switcher in my header.php file. The code would change my header image dependent on the category being viewed. That’s the goal.
I’ve read the codex and studied support forums on similar things but I can’t get it to work. I’ve been at it for a couple weeks and posted for help previously. That post only got 1 response from a kind moderator but suggested a possible plugin that doesn’t really work for me.
I’m desperate for assistance getting the code right. Can anybody spare a few minutes to help or point me in the right direction.
I’m probably do for a “duh? how’d I miss that” but I can’t seem to get it right.
The following is my original theme code and then the proposed switching code.
original header.php code:
<div id="headerimage" onclick="location.href='<?php bloginfo('home')); ?>' style=cursor: pointer;"> </div>
proposed method for switcher:
<div id="headerimage" onclick="location.href='<?php bloginfo('home')); ?>' style=cursor: pointer;"> <?php if( is_home() ) echo ('header.jpg'); elseif(is_category('movies' || 'television') echo ('movieheader.jpg'); else echo ('header.jpg) ?>
my style.php file normally addresses #headerimage with:
background-image: url(<?php echo $water_header_image; ?>);
if it helps, there is also an array in my theme’s function.php file which defines name for header image as either the full URL or filename if in the theme folder (which is where my jpg’s are located).
Do I need to change the style.php entry? is my approach wrong? what am I missing. Could somebody please help?
- The topic ‘Need help – proper format conditionals for category specific header images?’ is closed to new replies.