Kriuchko
1/8/2019 - 2:48 PM

Menu check submenu menu check subitems menu check child items menu check childrens

Wordpress menu check submenu

class MyWalker extends Walker_Nav_Menu
{
    function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output)
    {
        $element->hasChildren = isset($children_elements[$element->ID]) && !empty($children_elements[$element->ID]);
        $element->childrenCount = count( $children_elements[$element->ID] );

        return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
    }

    function start_el(&$output, $item, $depth, $args)
    {
        global $wp_query;

        // you know can access $item->hasChildren to do anything you want..
    }
}