Skip to content

Instantly share code, notes, and snippets.

@DomagojGojak DomagojGojak/header.php
Last active Apr 12, 2017

Embed
What would you like to do?
<!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>
@michellomp

This comment has been minimized.

Copy link

michellomp commented Feb 24, 2016

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 ?

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.