I'm building a site's navigation bar programmatically, using the following code:

wp_update_nav_menu_item($menu->term_id, 0, array(
    'menu-item-title' =>  $page_data->post_title,
    'menu-item-classes' => 'main',
    'menu-item-url' => '/', 
    'menu-item-status' => 'publish'));

this adds menu items to my navigation bar and works well. I use this to pre-populate a number of menu items when site is created.

The question is how do I delete a menu item from the nav menu? (for example if user wants different menu items in the nav bar). I know that I can use exclude, but that doesn't seem like the right solution since I don't want to constantly manage the exclude list based on user changes.

another question: how do I change menu order via code?


  • you want to remove it completely from database ?
    – Amit Kosti
    Aug 5, 2012 at 9:14

1 Answer 1


As the menu Items are stored as a post type. Not sure but I think we can use wp_delete_post() to programmatically remove it. That will completely remove the menu item from database, So you cant ever have that menu item again.

  • wp_delete_nav_menu_item() is coming but thanks for this solution.
    – Ryan Bayne
    Oct 17, 2015 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.