This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html <?php language_attributes(); ?>> | |
<head> | |
<meta charset="<?php bloginfo( 'charset' ); ?>"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="profile" href="http://gmpg.org/xfn/11"> | |
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>"> | |
<?php wp_head(); ?> | |
</head> | |
<body <?php body_class(); ?>> | |
<header> | |
<ul class="mega-menu"> | |
<?php | |
$locations = get_nav_menu_locations(); | |
if ( isset( $locations[ 'mega_menu' ] ) ) { | |
$menu = get_term( $locations[ 'mega_menu' ], 'nav_menu' ); | |
if ( $items = wp_get_nav_menu_items( $menu->name ) ) { | |
foreach ( $items as $item ) { | |
echo "<li>"; | |
echo "<a href=\"{$item->url}\">{$item->title}</a>"; | |
if ( is_active_sidebar( 'mega-menu-widget-area-' . $item->ID ) ) { | |
echo "<div id=\"mega-menu-{$item->ID}\" class=\"mega-menu\">"; | |
dynamic_sidebar( 'mega-menu-widget-area-' . $item->ID ); | |
echo "</div>"; | |
} | |
echo "</li>"; | |
} | |
} | |
} | |
?> | |
</ul> | |
</header> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to integrate your mega menu in a nav walker menu ?
For example Mega_Menu extends Walker_Nav_Menu and then use that Mega_Menu on condition like if ( in_array( 'has-mega-menu', $item->classes ) ) then use Mega_Menu else use normal nav menu or the best is to integrate the condition in function start_el and always call Mega menu ?