• Hello !

    I need help to creating a very custom menu with wp_get_nav_menu_items hook.

    I want to create a sub menu to a existant one, with sub sub menu inside. The sub menu work correctly but when I want to add sub sub menu to a sub menu, they are not placed below but after the menu.

    I use that to create item of my menu :

    
    $new_item = new stdClass;
    $new_item->menu_item_parent = $parent;
    $new_item->ID = random_int(1000, 9999);
    $new_item->url = $url;
    $new_item->title = $title;
    $new_item->menu_order = $order;
    

    I think is the menu_order I don’t understand perfectly..

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Menu order is the order that items appear in the backend menu GUI, regardless of indent/child status. TBH, I’m unsure what would be appropriate for inserted items outside of the GUI. Relation to other items may not matter as long as the order within the sub-sub-menu is as you wish. Even that may not matter, what would matter is the order in which items are inserted into the array. I think it’s past time to utilize order data by the time the filter fires.

    Are you sure the $parent value is correct? Even that may not matter for the same reason menu_order may not matter. I suspect you’re inserting your items into the overall array at the wrong place. At this point, the structure of the array itself is what determines the eventual menu HTML.

Viewing 1 replies (of 1 total)
  • The topic ‘Need help with creating menu with wp_get_nav_menu_items hook’ is closed to new replies.