Dynamic Highlighting Menu for Child Pages
-
I used the Dynamic Menu Highlighting script to create active states for my nav based on the page being viewed. Now, I have child pages that I also want to show the active state to reflect what “section” a visitor is in.
Example: If “web design” is a child page of “portfolio”, portfolio would be highlighted in the nav.
I can do this using OR statements in my php, but that gets messy and has to be updated if a new child-page is added. Here is the code I came up with the messy way:
if ( is_page('porfolio') || is_page('web-design') || is_page('print-design') ) { $current = 'n-festival-info'; }
Does anyone have a solution that would solve this dynamically? I tried using the
if($post->post_parent)
code that I use to build out sub-navs when child-pages are detected, but that got messed up quickly.Any ideas?
- The topic ‘Dynamic Highlighting Menu for Child Pages’ is closed to new replies.