I am trying to make a custom menu (based on twentyeleven) with three stances: passive, hover & current page. I am using a single sprite graphic which is called up via css for all stances of the button graphics, which is why there are x/y coordinates for the background image. The first two stances work fine, but I can't seem to get the last one working. It should show a different background image (or to be more precise a different region of the sprite image) if it's on a particular site that has a specific title.
I looked into the codex and found the
if ( is_page('page_title') ) conditional here: http://codex.wordpress.org/Dynamic_Menu_Highlighting
So I put the following into the header:
<?php
if ( is_page('page_title') ) { $current = 'menu-icon-01'; $xcord = '-202px'; $ycord = '144px';}
elseif ( is_page('page_title2') ) { $current = 'menu-icon-02'; $xcord = '-303px'; $ycord = '144px';}
elseif ( is_page('page_title3') ) { $current = 'menu-icon-03'; $xcord = '-404px'; $ycord = '144px';}
elseif ( is_page('page_title4') ) { $current = 'menu-icon-04'; $xcord = '-505px'; $ycord = '144px';}
elseif ( is_page('page_title5') ) { $current = 'menu-icon-05'; $xcord = '-808px'; $ycord = '-51px';}
elseif ( is_page('page_title6') ) { $current = 'menu-icon-06'; $xcord = '-909px'; $ycord = '-144px';}
?>
<style type="text/css">
#<?php echo $current; ?> { background:url("./images/sprites.png") <?php echo $xcord; ?> <?php echo $ycord; ?> no-repeat; height: 30px; width: 100px }
</style>
and further down in the body in have the menu
<ul id="menu-icon">
<li id="menu-icon-01"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="*"><img src="./images/transparent.gif" width="100" height="30" alt="menu-home"></a></li>
<li id="menu-icon-02"> <a href="*" title="*"><img src="./images/transparent.gif" width="100" height="30" alt="*"></a></li>
<li id="menu-icon-05"> <a href="*" title="*"><img src="./images/transparent.gif" width="100" height="30" alt="*"></a></li>
<li id="menu-icon-04"> <a href="*" title="*"><img src="./images/transparent.gif" width="100" height="30" alt="*"></a></li>
<li id="menu-icon-06"> <a href="*" title="*"><img src="./images/transparent.gif" width="100" height="30"></a></li>
</ul>
For some odd reason the php code does not produce any variables at all. Has anybody got an idea why that might be?
And does if ( is_page('page_title') ) only work on pages, or would posts work too?