Dynamically highlight menu when viewing posts that belong to a category
-
Greetings,
Ive created a hard-coded navigation menu with an image sprite that utilizes<?php if ( is_page('')) { echo ' class="" '; } ?>
to dynamically highlight each page, however I would like to keep the associated page highlighted once the visitor clicks on a post and views it from the single template (I have multiple single page templates)….right now this does not work, but I dont know how to make it work.Here is my current nav markup:
<ul id="nav"> <li> <a href="/" id="logo"></a> </li> <li> <a href="/" id="home" <?php if ( is_page('events')) { echo ' class="home_highlight" '; } ?>></a> </li> <li> <a href="#" id="artists" <?php if ( is_page('artists')) { echo ' class="artists_highlight" '; } ?>></a> </li> <li> <a href="/media" id="media" <?php if ( is_page('media')) { echo ' class="media_highlight" '; } ?>></a> </li> <li> <a href="/blog" id="blog" <?php if ( is_home('blog')) { echo ' class="blog_highlight"'; } ?>></a> </li> <li> <a href="#" id="store" <?php if ( is_page('store')) { echo ' class="store_highlight" '; } ?>></a> </li> <li> <a href="#" id="contact" <?php if ( is_page('contact')) { echo ' class="contact_highlight" '; } ?>></a> </li> </ul>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Dynamically highlight menu when viewing posts that belong to a category’ is closed to new replies.