Skip to content

Instantly share code, notes, and snippets.

@zzramesses
Last active January 26, 2018 15:05
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save zzramesses/0e7cd411045e11571448 to your computer and use it in GitHub Desktop.
Save zzramesses/0e7cd411045e11571448 to your computer and use it in GitHub Desktop.
Foundation Off-Canvas WordPress Menu
class Off_Canvas_Walker extends Walker_Nav_Menu {
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
$element->has_children = !empty( $children_elements[$element->ID] );
$element->classes[] = ( $element->has_children ) ? 'has-submenu' : '';
parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
}
function start_lvl( &$output, $depth = 0, $args = array() ) {
$output .= "\n<ul class=\"left-submenu\">\n";
$output .= "\n<li class=\"back\"><a href=\"#\">Back</a></li>\n";
}
}
<aside class="left-off-canvas-menu">
<?php wp_nav_menu(
array(
'theme_location' => 'the menu you want to use',
'container' => false,
'menu_id' => '',
'menu_class' => 'off-canvas-list',
'walker' => new Off_Canvas_Walker()
)
);
?>
</aside>
@tsquez
Copy link

tsquez commented Apr 1, 2015

This looks really cool! Going to give it a try, thanks for the effort 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment