Looking to use walker to give a specific container to a submenu
-
Can someone help me see what am I doing wrong I am trying to use the nav walker to wrap one container around a certain group of submenu below is the menu structure.
-Test
–Subtest <— Looking to only wrap the container around this levels children
—Subsubtest
—Subsubtest 2
–Subtest 2
-Test 2
–Subtest <— Looking to only wrap the container around this levels children
— Subsubtest
-Test 3So anything that has both parent and children.
<pre><code>class OBE_Mega_Sub_Menu extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); // $classes = $args-> $link_depth = $args->depth; if($args->walker->depth && $depth == 1) { $output .= "\n$indent<div class='container'><div class='sub-menu-holder flex flex-column'>\n"; } else { $output .= "\n$indent<ul class='sub-menu' data-slide><div class='container $depth $link_depth'><div class='sub-menu-holder'>\n"; } } function end_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $link_depth = $args->depth; if($args->walker->depth && $depth == 1) { $output .= "$indent</div></div>\n"; } else { $output .= "$indent</div></div></ul>\n"; } } } </code></pre>
I’ve tried a few combinations but it always goes to the else.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Looking to use walker to give a specific container to a submenu’ is closed to new replies.