Skip to content

Instantly share code, notes, and snippets.

@lexthor
Forked from fieldoffice/sub-menu-wrap
Created November 13, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lexthor/d3d1d51cc329469c01dffbc217438d0f to your computer and use it in GitHub Desktop.
Save lexthor/d3d1d51cc329469c01dffbc217438d0f to your computer and use it in GitHub Desktop.
Wordpress - add div wrapper around sub-menu
/* EXTEND SUBNAV
******************************************/
class submenu-wrap extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<div class='sub-menu-wrap'><ul class='sub-menu'>\n";
}
function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul></div>\n";
}
}
<?php wp_nav_menu(array(
'walker' => new submenu-wrap()
)); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment