In wp_nav_menu i use for the menu, with custom walker, i can get the $depth parameter in the start_el function
function start_el(&$output, $item, $depth, $args)
but, outside this wp_nav_menu(), how can i get the depth of the menu for the clicked item ? For instance :
- Home
- level1menuelement1 -level2menuelement1 (first element of first submenu) -level2menuelement2 (second element of first submenu)
- level1menuelement2
- ...
In that case, i want to know if my post is in a level 1 or not, to display a specific block or not.
Is there a codex function allowing to facilitate the retrieving of this depth or is it achieved programmatically ?
Thanks
if ($j('.current-menu-ancestor').length == 0){$j('#myblock').hide();}
This works for me. But if you have a php solution, i'll be glad to have it for learning purpose.