[wp-hackers] wp_nav_menu?

Travis Northcutt travis at travisnorthcutt.com
Mon Apr 4 16:16:13 UTC 2011


I'm assuming (and you know what they say about that...) that Thomas is
looking for a way to apply classes automatically, rather than having to
apply them manually to each menu item.
--
Travis Northcutt


On Mon, Apr 4, 2011 at 11:10 AM, Chip Bennett <chip at chipbennett.net> wrote:

> By "Control Panel", do you mean Dashboard -> Appearance -> Menus?
>
> If so, then ensure that you have enabled display of custom classes for menu
> items:
>
> 1) Click the "Screen Options" tab in the upper right-hand corner
> 2) Enable the check-box for "CSS Classes"
> 3) Edit each menu item as needed, by adding custom classes to the "CSS
> Classes (optional)" text field
>
> (And if this is too simplistic, or not what you're looking for; my
> apologies.)
>
> Chip
>
> On Mon, Apr 4, 2011 at 11:00 AM, Thomas Belknap
> <dragonfly at dragonflyeye.net>wrote:
>
> > 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?
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> 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