Archived topic
Support for Walker_Nav_Menu
8 replies · Started by Krzysztof on September 1, 2014
Hello :) Could You add to all wp_nav_menu a walker? I need this to do something really cool but I don't want to change GeneratePress PHP files in each new version.
I can't add a walker to the nav by default - but when this new version is released remind me to give you a chunk of code that will replace the current menu with a menu that accepts a walker.
I should be submitting the newest version tonight.
Thanks!
Do you still need the code to do this?
Let me know :)
Yes, I still need a walker - I must separate arrow that inform of existing submenu and show submenu only when cursor is above arrow :)
Ok, give this a go: https://gist.github.com/generatepress/47e6abb67b41883e1910
You should only end up with one add_action and one remove_action, which you should match with the navigation position setting you have set in the Customizer.
You can change the name of the Walker to whatever you name your walker.
Hope this helps :)
Hmm I need to change something in GeneratePress files? Because now it doesn't work and I have two navigation menu.
remove_action return false even when I changed it to:
remove_action('generate_after_header', 'generate_add_navigation_after_header', 5);
That should go in your functions.php file or in a new plugin you can create easily with a plugin called "Pluginception".
I updated the Gist so the remove action should fire: https://gist.github.com/generatepress/47e6abb67b41883e1910
If "after_setup_theme" doesn't work, try "wp".
I won't be around most of today - but will check back as soon as I get back in my office.
Yeah, now it's work perfect :D Thank You Tom!