wp_nav_menu?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

wp_nav_menu?

Thomas Belknap
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
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: wp_nav_menu?

Chip Bennett
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
<[hidden email]>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
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: wp_nav_menu?

Travis Northcutt
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 <[hidden email]> 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
> <[hidden email]>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
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: wp_nav_menu?

Thomas Belknap
In reply to this post by Chip Bennett
Oh, boy. No, not too simple at all. In fact, exactly what I was looking for.
#enduserfail
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers