[wp-hackers] wp_nav_menu?

Thomas Belknap dragonfly at dragonflyeye.net
Mon Apr 4 16:00:22 UTC 2011


Am I wrong in thinking that the only way to modify the output of menus is to
use the above hook? If I wanted to add a class to each menu item, I would
have to use a regular expression to pull each one out? Most everything I see
suggests some variation of the following:

function add_markup_pages($output) {
    $output= preg_replace('/menu-item/', 'first-menu-item menu-item',
$output, 1);
$output=substr_replace($output, "last-menu-item menu-item",
strripos($output, "menu-item"), strlen("menu-item"));
    return $output;
}
add_filter('wp_nav_menu', 'add_markup_pages');

The above code is not quite what I need, of course. But I find it strange
that we can't just apply classes in the Control Panel for menus?


More information about the wp-hackers mailing list