Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

motoDrizzt on "Adding submenu to frontend navigation menu"

$
0
0

Hi all.

I'm developing a plug-in, and one of the things I need is to be able to build and entire navigation menu from scratch.

Up to now I've been able to use wp_create_nav_menu to create a navigation menu, retrieve it when needed with wp_get_nav_menu_object, and add and modify first level menu items with wp_update_nav_menu_item.

Problem I'm facing now, I've got not the palest idea how to add a sub menu to the first level item I've created. I was thinking that calling wp_update_nav_menu_item with the first level menu item as parent would have worked, but it doesn't.

Example:
I create a nav menu. It' term_id is 600;
Then I create a menu item with wp_update_nav_menu_item: it works, and newly created menu item has ID 602
Now I want to add a child to menu item 602, but if I call wp_update_nav_menu_item with 602 as first parameter it gives error; checking function code, it seems it fails on trying to check if my menu item is a nav menu, which obviously it isn't.

What I'm supposed to do, then?


Viewing all articles
Browse latest Browse all 8245

Trending Articles