[wp-hackers] Adding class to first menu item of submenu inwp_nav_menu

Lox lox.dev at knc.nc
Tue Jun 29 21:57:06 UTC 2010

2010/6/30 ErisDS <erisds at gmail.com>:
> Is there another way to inject additional fields/ content into a navigation
> item that I'm missing?

In my Gecka Submenu plugin, I have used a filter to add the nav_menu
item description in generated menu without using a walker:

// filter to show the description of menu items if asked
add_filter('walker_nav_menu_start_el', array($this,
'walker_nav_menu_start_el'), 10, 4);


public function walker_nav_menu_start_el ($item_output, $item, $depth, $args) {
        if($args->show_description) {

            $desc .= ! empty( $item->description ) ? '<span
class="description">'    . esc_html( $item->description        )
.'</span>' : '';

            if($desc) $item_output = str_replace('</a>', $desc.'</a>',

        return $item_output;

lox.dev at knc.nc

More information about the wp-hackers mailing list