using;
$args = array( 'menu' => 'mainmenu', 'container' => 'ul', 'menu_class' => 'span-10 clearfix', 'after'=>'/');
wp_nav_menu($args);
which gives me;
london/munich/artists/fairs & events/publications/news/contact/
but using the args (or similar) can i remove the / from contact?
any help welcome!
Here is a completely different approach to the problem. Since the slashes may be considered to be presentational, they should not go into the HTML. Users without CSS just get to see a regular list.
You could then use CSS to restyle the list and add the slashes in between.
Check it out here.
Note: this will not work in IE7 and older. IE7 does support
:first-child
but:before
only works from IE8.First +1 for using blueprint css 🙂
Second: Yes, separators are just presentational and shouldn’t be part of the menu (screenreader using people would be confused). So here you get a simple function to add separator-css-classes or any other additional classes whereever you need them. Just modify the three vars to your needs.
And now here’s the function that let you exactly target a single nav menu item in a specific location within a specific menu. You just have to modify the first three vars
$menu_location
,$menu_name
, &$menu_item
to your needs.You can then style your separator as you need it from inside your css file.
If you can move the
/
to before the links ('before' => '/'
instead of'after' => '/'
), that would make it much easier to filter out; you could do it like this:And this is how you should be able to add the
/
after (even if not recommended). For some reason this doesn’t work as expected, even if i get the right$args
when iprint_r
it (see#
-uncommented code). It adds to the first (in my testcase) instead of the last element.@John P Bloch @Geert – Could you pls give this a try and tell me if this works wrong for you too? Thanks!