Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

thanks!

share|improve this question
    
you want to remove it completely from database ? –  amit Aug 5 '12 at 9:14
add comment

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
thanks - that worked :) –  OS. Aug 5 '12 at 10:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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