Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Primary Menu using custom Walker
*
* Copieid the contents of genesis_do_nav() in /genesis/lib/structure/menu.php, then changed args
*/
function be_primary_menu() {
//* Do nothing if menu not supported
if ( ! genesis_nav_menu_supported( 'primary' ) )
return;
//* If menu is assigned to theme location, output
if ( has_nav_menu( 'primary' ) ) {
$class = 'menu genesis-nav-menu menu-primary';
if ( genesis_superfish_enabled() )
$class .= ' js-superfish';
$args = array(
'theme_location' => 'primary',
'container' => '',
'menu_class' => $class,
'echo' => 0,
'walker' => new Walker_Nav_Menu_Dropdown(),
);
$nav = wp_nav_menu( $args );
//* Do nothing if there is nothing to show
if ( ! $nav )
return;
$nav_markup_open = genesis_markup( array(
'html5' => '<nav %s>',
'xhtml' => '<div id="nav">',
'context' => 'nav-primary',
'echo' => false,
) );
$nav_markup_open .= genesis_structural_wrap( 'menu-primary', 'open', 0 );
$nav_markup_close = genesis_structural_wrap( 'menu-primary', 'close', 0 );
$nav_markup_close .= genesis_html5() ? '</nav>' : '</div>';
$nav_output = $nav_markup_open . $nav . $nav_markup_close;
echo apply_filters( 'genesis_do_nav', $nav_output, $nav, $args );
}
}
add_action( 'genesis_after_header', 'be_primary_menu' );
remove_action( 'genesis_after_header', 'genesis_do_nav' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.