It’s not working for two reasons.
- You have
echo
set to false. This means it won’t output anything unless youecho
it manually. - The resulting HTML structure is invalid.
You have items_wrap
set it %3$s
. This means that the individual menu items, which are <li>
tags, will be output without a wrapper. That would make the final structure this:
<ul>
<li>
<div class="dropdown-menu">
<li></li>
<li></li>
<li></li>
</div>
</li>
</ul>
That’s not valid HTML. The <li>
tags need to be in an <ol>
or <ul>
, not a <div>
. The simplest solution is to change the div to a <ul>
:
<li>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<?php
wp_nav_menu(array(
'theme_location' => 'header_menu_location',
'echo' => false,
'items_wrap' => '%3$s'
));
?>
</ul>