Reply To: Child Pages – Active Nav

#2174
Livemeshlivemesh
Keymaster

These classes are controlled and implemented in WP Core and are not controlled by the theme. If there is a limitation that you see with the current menu, it should be addressed by WP Menu implementation. The below documentation of WP Nav Menu indicates that it should get highlighted –

http://codex.wordpress.org/Function_Reference/wp_nav_menu#Menu_Item_CSS_Classes

I did a test and looks like the the parent does get highlighted if it exists in the menu. For now, I would say try to have both conditions like this for best results –

            // make the parent of current page active for lavalamp highlight
            $('#primary-menu > ul > li.current-page-ancestor').first().addClass('active');

            // make the current page active for lavalamp highlight - top list cannot have both a parent and current page item
            $('#primary-menu > ul > li.current-page-item').first().addClass('active');

            // make the parent of current page active for lavalamp highlight
            $('#primary-menu > ul > li.current-menu-ancestor').first().addClass('active');

            // make the current page active for lavalamp highlight - top list cannot have both a parent and current page item
            $('#primary-menu > ul > li.current-menu-item').first().addClass('active');

The class active won’t be added twice by JQuery and hence should not hurt to have the above piece of code. Thanks