is it possible to add some kind of class like ‘arrow’ or a span inside the menus that have submenus (in WordPress)?
it seems that you can do this is using javascript, but I want to know if there’s a PHP solution…
in WP 3.0, I saw that active menus have the “parent” or “ancestor” classes on them, but this is only for active menu, and I need it for inactive ones as well
This functionality really should be in WordPress core!
Anyway, I had a look at the menu template source you sent in a comment on the other answer, and have found a (rather hacky) way to add a class on menu items with children. It basically subclasses the default walker to extend its default behaviour. It’s probably best if you put it in your theme’s
functions.php. Here’s the code:To call it, you’ll need to add the
walkerargument when you callwp_nav_menu()in your theme, like so:Hope that works for you! I’ve only tested it superficially, but it seems to work. Let me know if there are any edge cases where adding the class fails.