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>
A custom “walker” class?
http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output
Option 1:
Assuming you’ve created your menu by using Appearance -> Menus , you can try the following.
Once you’ve done the above steps, each of the menu items will now have a “CSS Classses” textbox showing where you can on an individual basis assign CSS Classes (have a look at the screen grab).
Option 2:
You could also try http://codex.wordpress.org/Function_Reference/wp_nav_menu#Adding_Conditional_Classes_to_Menu_Items
Option 3:
Provided the above 2 options don’t work you have the 3rd option of using jQuery.
HTH
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.
You’ll have to start in wp-includes/nav-menu-template.php to Copy and paste the function to your theme’s functions.php and change the name or use a filter in functions.php to change selected markup of the hook. And possibly take a look in wp-includes/nav-menu.php as well.
Sorry I can’t provide more detail.