[wp-hackers] wp_nav_menu too simplistic?

John Bloch jbloch at olympianetworks.com
Tue Apr 6 20:42:33 UTC 2010

A plugin can absolutely do it. Just put it in the plugin's main file and
activate the plugin. I said theme functions.php file because this is more
properly handled by a theme. But it's absolutely possible to do this with a

You're right about extending Walker_Nav_Menu. I was copying and pasting
hastily, and didn't want to do further cutting/pasting.

I'm saying this is the API that the programmers building this have chosen.
Before 3.0 it took many hundreds, sometimes thousands of lines of
programming to add custom post types. Now it can be done in under 10. As the
nav menus get built out more, the API will get tweaked to allow easier and
more flexible programming (although, I have to say, it's pretty flexible
right now).

John P. Bloch

On Tue, Apr 6, 2010 at 4:24 PM, Otto <otto at ottodestruct.com> wrote:

> On Tue, Apr 6, 2010 at 3:17 PM, Otto <otto at ottodestruct.com> wrote:
> > On Tue, Apr 6, 2010 at 3:13 PM, John Bloch <jbloch at olympianetworks.com>
> wrote:
> >> This custom walker class will give you a filter to directly modify the
> >> url of individual menu items. Put this into your theme's function file
> >> and, when you call the menu, add "walker=Custom_Walker_Nav_Menu" to
> >> the function's arguments.
> >
> > So what you're saying is that you can't make a plugin do it, it has to
> > be a theme that does it, by modifying the call to wp_nav_menu.
> Ahh, no, a plugin can do it. There's a filter you can use to force the
> walker, "wp_nav_menu_args".
> Rather a long way to go though. And it doesn't allow for multiple
> plugins creating different types of menu items, since only one walker
> can be used.
> BTW, in your example, it would actually make more sense for
> Custom_Walker_Nav_Menu to extend Walker_Nav_Menu. Then you could
> override just the start_el function, leaving the rest alone.
> -Otto
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list