Skip to content

Instantly share code, notes, and snippets.

@narkan
Last active September 29, 2017 19:18
Show Gist options
  • Save narkan/7eb2997e272ead3c580db9f26f2d3adb to your computer and use it in GitHub Desktop.
Save narkan/7eb2997e272ead3c580db9f26f2d3adb to your computer and use it in GitHub Desktop.
Foundation 6 navigation menu for Wordpress: functions.php
<?php
/***** FUNCTIONS.PHP **********/
class F6_DRILL_MENU_WALKER extends Walker_Nav_Menu {
/*
* Add vertical menu class
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"vertical menu\">\n";
}
}
function f6_drill_menu_fallback( $args ) {
/*
* Instantiate new Page Walker class instead of applying a filter to the
* "wp_page_menu" function in the event there are multiple active menus in theme.
*/
$walker_page = new Walker_Page();
$fallback = $walker_page->walk( get_pages(), 0 );
$fallback = str_replace( "children", "children vertical menu", $fallback );
echo '<ul class="vertical medium-horizontal menu" data-responsive-menu="drilldown medium-dropdown" style="width: 100%;">' . $fallback . '</ul>';
}
<!-- Foundation 6 navigation menu for Wordpress
<div class="row">
<div class="title-bar" data-responsive-toggle="the-menu" data-hide-for="medium">
<button class="menu-icon" type="button" data-toggle></button>
<div class="title-bar-title">MENU</div>
</div>
<div class="top-bar" id="the-menu">
<div class="top-bar-right">
<?php
wp_nav_menu( array(
'container' => false,
'menu' => 'Primary Menu',
'menu_class' => 'vertical medium-horizontal menu',
'theme_location' => 'primary',
'items_wrap' => '<ul id="%1$s" class="%2$s" data-responsive-menu="drilldown medium-dropdown" style="width: 100%%;">%3$s</ul>',
//Recommend setting this to false, but if you need a fallback...
'fallback_cb' => 'f6_drill_menu_fallback',
'walker' => new F6_DRILL_MENU_WALKER()
) );
?>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment