I have the same issue. Some answers claim that you can use $args->has_children
or $args[0]->has_children
, but it’s never added to $args. Sometimes, has_children
is added under $args->walker->has_children
, but it’s always set to false
, in other words, useless…
As a work around, the current template that I’m using adds a class to items that contain children (menu-item-has-children), so I searched for it under $item->classes
.
function end_el( &$output, $item, $depth = 0, $args = array() ) {
if( !empty($item->classes) &&
is_array($item->classes) &&
in_array('menu-item-has-children', $item->classes) ){
// This guy has children
}
}
I guess, you could add a mark in your start_el function and then search for it…
I hope this helps. If you have a better solutions, please share it.