Support » Themes and Templates » Custom Walker Functions/Classes for wp_nav_menu won't work

  • Abledaccess


    I’m having trouble understanding how to deploy a walker class to a wp_nav_menu and finding an adequate explanation for how one works.

    Essentially what I’m doing is building an accessibility driven theme and I want to clean up the markup, in my wp_nav_menu by eliminating the redundant classes and IDs WordPress generates. But I’d still like to have a user add their own classes via the option the backend provides.

    And not only that, I’d really like the walker to inject classes for the active page, plus surround the active link with tags, say, as not to rely on CSS alone.

    Roger Johansson posted an article doing the exact thing I’d really like to do with wp_list_pages, which I got working, but it won’t translate for me to wp_nav_menu.

    Any help anyone could provide would be greatly appreciated. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Abledaccess


    My apologies. That’s a tall order I requested. Let me break it down a bit — not that I think me breaking it down will make it any easier to solve.

    I got the menu working, meaning it is stripping all the rendancies I want it to take out, when no menu is selected in the backend (see: But once I select the menu I want to display, which is essentially the same menu that is there, now, plus one extra home link, I get all kinds of errors:

    Warning: Missing argument 5 for Clean_Walker::start_el() in /Users/Johnny/Sites/Abledaccess/wp-content/themes/FSSFive/functions.php on line 9

    For instance. I’m using this code,, for my walker in my functions template file and;

    <?php $walker = new Clean_Walker(); wp_nav_menu(array("container" => "ul", "menu_class" => "fl-tabs fl-clearfix fl-tabs-left", "theme_location" => "main_nav", "walker" => $walker )); ?>

    To call on it. Again any help anyone can provide would be fantastic.

    (A related aside; I now understand what happened in my original post, with the <strong> tag, and the seemingly arbitrary bolded text. It should read “surround the active link text with <strong> tags. Hopefully that fixes it. Guess we’ll soon see.)

    Hey just wondering if you figured this out. I’m trying to transfer my Walker class between my wp_list_pages (which works OK) and the wp_nav_menu (where I get similar errors).


    Nothing to report. I didn’t get anywhere. I convinced myself it’s best to leave all the hooks in. Sorry.


    I have an even worse problem: wp_nav_menu won’t use my walker! I know I am passing the walker object to it, I have quintuple-checked that I have overriden the methods correctly, and the methods simply aren’t called! I even redefined start_el() to just exit; for testing – that would stop page rendering if start_el() were called, but the page still renders unmodified. I’m at my wit’s end.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Walker Functions/Classes for wp_nav_menu won't work’ is closed to new replies.