dynamic menu and category highlighting
-
I’m full of questions today!
Okay, I’ve managed to get the dynamic menu highlighting to work with categories – no problem. But now, what I need to do is this:
When you go to a single post page, the menu item in the navigational bar should be highlighted as to what category the single post is located in. (Did that make sense?)
In ither words, my menu bar is set up so that the menu items are category names. I’ve got it working so that, when you click on “Page two”, then the menu item for “Page Two” is highlighted. However, if you click on a single post *within* the “Page Two” category, the menu item is *not* highlighted.
I want it to be highlighted, yet I can’t seem to figure out where to put my code to make it do so.
Right now, I have this in my “header.php” file, between the
<head></head>tags:<?php
if ( is_home() ) { $current='home'; }
elseif ( is_category('') ) { $current='current-cat'; }
?><style type="text/css">
ul#topnav li.<?php echo $current; ?> a {background-color:#ED4529;}
ul#topnav li.<?php echo $current; ?> li a {background-color:transparent;}
</style>(yes, that reference to “is_home”is necessary)…
and in the “footer.php” file, I have this:
<div id="topmenu">
<ul id="topnav">
<?php
if (is_home() ) { $current='home';
echo '<li class="home"><a href="index.php">Home</a></li>';
wp_list_cats('optionall=1&exclude=1&hide_empty=0');}
else { wp_list_cats('optionall=1&hide_empty=0');}
?>
</ul>
</div> <!--closing #topmenu-->By the way, the header is actually within the footer.php file, because I have my site source-ordered – content first π
So, what would I need to change there to make the single post pages recognize what category they are in, and then highlighting the correct menu item for the single post page?
I hope my question makes sense…sometimes I don’t even understand the crap that comes out of my head! π
The topic ‘dynamic menu and category highlighting’ is closed to new replies.