Does anyone have a working example of a WordPress menu outputted manually? The one on the Codex didn’t seem to work, though my menu_name slug of “Footer” can’t be that complicated..? I need to add offscreen spans within external menu links for accessibility purposes. I already have CSS classes; what I need is specific markup added via the functions.php file.
The basic code I’m looking for (see list items w/ ‘external’ class. Hrefs changed to # for code brevity, they link offsite in real life):
<ul id="menu-footer" class="menu">
<li class="menu-item">
<a href="#">About Us</a>
</li>
<li class="external menu-item">
<a title="Link opens in a new window." target="_blank" href="#">Terms & Conditions <span class="offscreen">Opens in a new window</span></a>
</li>
<li class="menu-item">
<a href="#">Comments Policy</a>
</li>
<li class="external menu-item">
<a title="Link opens in a new window." target="_blank" href="#">Privacy Statement<span class="offscreen">Opens in a new window</span></a>
</li>
<li class="menu-item">
<a href="#">Contact Us</a>
</li>
</ul>
Answer: the nav menu has to be registered & assigned to the theme for the Codex example to work. DUH!
in functions.php:
Assign menu(s) to your theme:
Back in functions.php:
Now call the function in your template:
Boom.