Dynamic Menu Highlighting
-
Hi,
I’m looking for some help and would be grateful for some pointers.I’ve implemented the dynamic menu highlighting following the the relevant codex article. I’ve managed to get the menu just as I want. However I’ve run into a problem with the conditional statements when I’ve added a sub menu to the original menu.
This additional submenu also needs highlighting just as the main menu, however I would like the main menu to keep the correct item highlighted.
For example if I’m looking at a page called Services which is highlighted, and within this page there are a range of sub menu items with the sub menu item highlighted that is currently being viewed.
I’ve implemented a sub menu that works fine, however I cant get the two working together. Here are my conditional statements.
<--This is for the main menu-->
<?php
if ( is_home('home') ) { $current = 'home'; }
elseif ( is_page('page 1') ) { $current = 'page 1'; }
elseif ( is_page('page 2') ) { $current = 'page 2'; }
elseif ( is_page('page 3') ) { $current = 'page 4'; }
elseif ( is_page('page 5') ) { $current = 'page 5'; }
elseif ( is_page('page 6') ) { $current = 'page 6'; }
?><!-- This is for the sub menu-->
<?php
if ( is_home('sub') ) { $current = 'sub'; }
elseif( is_page('sub 1') ) { $current = 'sub 1'; }
elseif ( is_page('sub 2') ) { $current = 'sub 2'; }
elseif ( is_page('sub 3') ) { $current = 'sub 3'; }
elseif ( is_page('sub 4') ) { $current = 'sub 4'; }
?>Would be extremely grateful for some advice.
Lee
- The topic ‘Dynamic Menu Highlighting’ is closed to new replies.