Determine if a navigation item has children
You can filter wp_nav_menu_objects and add the classes in one rush. You don’t even need a custom walker for that. add_filter( ‘wp_nav_menu_objects’, ‘add_has_children_to_nav_items’ ); function add_has_children_to_nav_items( $items ) { $parents = wp_list_pluck( $items, ‘menu_item_parent’); foreach ( $items as $item ) in_array( $item->ID, $parents ) && $item->classes[] = ‘has-children’; return $items; } The class has-children will … Read more