WordPress – remove items in menu

I would like a PHP code for delete all items in my menu on wordpress,
i had a workarround (delete & create) but i need to be logged to admin account.

example for add item in menu :

Read More
    $name = 'Menu';
    $menu = get_term_by( 'name', $name, 'nav_menu' );
    wp_update_nav_menu_item($menu->term_id, 0, array(
        'menu-item-title' => get_cat_name($_GET['ID']),
        'menu-item-object-id' => $_GET['ID'],
        'menu-item-db-id' => 0,
        'menu-item-url' => get_category_link($_GET['ID']),
        'menu-item-type' => 'taxonomy',
        'menu-item-status' => 'publish',
        'menu-item-object' => 'category',
        'menu-item-parent-id' => 0)
    );

Thanks.

Related posts

Leave a Reply

1 comment

  1. I had a need to delete all items in a existing menu, because the theme does not respect the “main menu” option, so i need to remove all items and put my on items.

    I made a javascript code to delete all of the menu items, all you need to do is open developers console in that menu page(where normally you will click in the “remove” option), and execute the code below:

    var items = $('.item-delete');
    for(var i=0;i<items.length;i++){ 
        items[i].click(); 
    }