I'm creating a script that automates build a wordpress site from another CMS. I've been able to change every setting: themes, options, subdomain, site title, etc.
But what is eluding me is being able to create custom menus. The code below SHOULD be able to do it for me. However it is not, and I am completely stumped on what to do.
This code is not being executed in the admin panel (Its not a plugin). Its actually sitting on top of wordpress and includes wp-load and wp-admin functions pages.
$mymenu = wp_get_nav_menu_object("Main Navigation Menu");
$menuID = (int) $mymenu->term_id;
$itemData = array(
'menu-item-db-id' => 0,
'menu-item-object-id' => $pageId,
'menu-item-object' => 'page',
'menu-item-type' => 'post_type',
'menu-item-parent-id' => 0,
'menu-item-position' => $itemOrder,
'menu-item-title' => $pageData['title'],
'menu-item-url' => get_permalink($pageId),
'menu-item-description' => $pageData['post_content'],
'menu-item-attr-title' => $pageData['post_excerpt'],
'menu-item-status' => 'publish',<br />
'menu-item-target' => ''<br />
);
$thisMenuItem = wp_update_nav_menu_item($menuID, 0, $itemData);
$itemData is the result of data coming in from another CMS plus the result of saving it off a post in wordpress to produce the menu item that I want in my menu. Any help on getting the wp_update_nav_menu_item to save would be very helpful. Again this is creating a custom menu without the use of the admin panel.`