If the user goes to a page other than the homepage then my header changes layout.
Everything works fine except for the function wp_nav_menu
.
First, I check whether the user is on the homepage or not. Depending on that outcome the user is shown one of two headers.
Here is the code:
<?php
$menu = wp_nav_menu( array( 'theme_location' => 'hoofdmenu' ) );
echo is_front_page() ? '' : '
<header>
<div class="hoofdmenu">
<div class="hamburger">
<a href="#" id="click-a"><img width="80" height="80" src="'.get_bloginfo('template_directory').'/images/hamburger.png"></a>
</div>
'.$menu.'
</div>
</header>';
?>
To keep it short I deleted the true
value of the if
statement.
Now the problem that I have is that the menu is placed completely outside the header
Here is the HTML output:
<div class="menu-hoofdmenu-container">
<ul id="menu-hoofdmenu" class="menu">
<li>Menu item 1</li>
<li>Menu item 2</li>
<li>Menu item 3</li>
</ul>
</div>
<header>
<div class="hoofdmenu">
<div class="hamburger">
<a href="#" id="click-a"><img width="80" height="80" src="http://www.url.nl/wp-content/themes/themename/images/hamburger.png"></a>
</div>
</div>
</div>
</header>
Any thoughts on why the wp_nav_menu
is placed outside the header
?
-------Update--------
echo is_front_page() ? '' : '
<header>
<div class="hoofdmenu">
<div class="hamburger">
<a href="#" id="click-a"><img width="80" height="80" src="'.get_bloginfo('template_directory').'/images/hamburger.png"></a>
</div>
'.wp_nav_menu( array( 'theme_location' => 'hoofdmenu' ) ).'
</div>
</header>