0

I seen many articles about navigation menu walking:

http://hookr.io/4.5.2/files/wp-admin-includes-class-walker-nav-menu-edit/

How to add a custom field in the advanced menu properties?

the problem is, its just a definition. How to actually make it alive?

1 Answer 1

3

You use the walker in your theme, wherever you call your nav menu.

So for example, if you currently have a "topnav" menu in your theme, like this:

wp_nav_menu(array('menu' => 'topnav');

and your custom walker is called "myCustomWalker", you would update the wp_nav_menu call like this:

wp_nav_menu(
    array(
        'menu'   => 'topnav', 
        'walker' => new myCustomWalker()
    ) 
);

Just make sure to work in a child theme, so that when your theme updates, your call to the new walker (and the walker itself) are not lost.

5
  • yea, thats right, but I cant see this method call at all
    – John Smith
    Jan 10, 2018 at 15:47
  • 1
    Could you clarify what you mean? Have you added the walker to your theme and tried to call it - and it's not outputting correctly?
    – WebElaine
    Jan 10, 2018 at 18:23
  • I was browsing for this method and its not used anywhere.
    – John Smith
    Jan 12, 2018 at 12:08
  • because Im using "ultimatum" theme
    – John Smith
    Jan 12, 2018 at 12:28
  • 1
    Not all themes use custom walkers. They're not always necessary, it just depends on what HTML you need from your nav_menus. If you want to start using one, create a child theme and use the walker there.
    – WebElaine
    Jan 12, 2018 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.