Site icon Hip-Hop Website Design and Development

Take away nav menu merchandise by script

I wish to create my customized nav menu utilizing a script in a wp plugin.
I am virtually there utilizing this tutorial. All I want is the choice to delete menu entries.

one thing like wp_delete_nav_menu_item($menuID, $itemID);

Instead, I might create a brand new menu utilizing wp_create_nav_menu($menu_name); so I don”t must delete the default entries of the menu I might be working with in any other case. The issue right here is, that the theme provides choices for the place of the menu like ‘header’ and I dont understand how i can outline a place for a newly created menu.

Hope somebody can provide recommendation so I can clear up considered one of these points.
Thanks!

That is the code I’m working with up to now. I want the code for the half to delete the default entries

//Add Menu
//Get Menu ID
$mymenu = wp_get_nav_menu_object('Header');
$menuID = $mymenu->term_id;

//Examine if Menu exists
if( !$mymenu ) {
    //Menu exists -> Delete the default entries
    //
} else {
    //Menu doesn't exist -> Create it
    $menuID = wp_create_nav_menu('Header');
}

//Create new Menu Entries
//Create Mother or father Menu Entries
$myPage = get_page_by_title( 'House' );
$itemData =  array(
'menu-item-object-id'   => $myPage->ID,
'menu-item-parent-id'   => 0,
'menu-item-position'    => 1,
'menu-item-object'      => 'web page',
'menu-item-type'        => 'post_type',
'menu-item-status'      => 'publish'
);
wp_update_nav_menu_item($menuID, 0, $itemData);