• in my WP MultiUser project i am designing a template for managing the menu like delete page, drag & reorder menu items by using below code
    (only the super admin can access the back-end admin panel)

    <?php
     $menu_name = 'header';
     if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
    $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
    $menu_items = wp_get_nav_menu_items($menu->term_id);
    $menu_list = '';
    $menu_list .='<div id="contentLeft"><ul>';
    foreach ( (array) $menu_items as $key => $menu_item ) {
        $title = $menu_item->title;
        $url = $menu_item->url;
        $menuorder = $menu_item->menu_order;
        $mdelete1 = wp_nonce_url( get_bloginfo('wpurl') . "/wp-admin/post.php?action=delete&post=" .$menu_item->object_id, 'delete-post_' . $menu_item->object_id);
        $menu_list .= '<li id="recordsArray_' . $menuorder.'">' .$title ;
        $menu_list .= ' <span> <a href="' . $mdelete1 . '"> Delete </a> </span></li> ';
    }
    $menu_list .='</ul></div>';
    } else {
    $menu_list = '<ul><li>Menu "' . $menu_name . '" not defined.</li></ul>';
    }
    echo $menu_list;
    ?>

    and for drag & drop i used jquery Link

    here is my updatedb.php code

    <?php global $wpdb;
    $action= mysql_real_escape_string($_POST['action']); $updateRecordsArray= $_POST['wpdb->postmetaArray']; if ($action == "updateRecordsListings"){ $listingCounter = 1; foreach ($updateRecordsArray as $recordIDValue) { $query = $wpdb->get_results("UPDATE records SET recordListingID = " . $listingCounter . " WHERE recordID = " . $recordIDValue); mysql_query($query) or die('Error, insert query failed'); $listingCounter = $listingCounter + 1;
    } echo '
    
    ';
        print_r($updateRecordsArray);
        echo '
    '; echo 'If you refresh the page, you will see that records will stay just as you modified.'; } ?>

    Now i can delete pages(menu items ) i can rearrange menu items by dragging but i am not able to update the same into the Database what i mean is: if i drag and reorder the pages the new order has to save in menu but it was not updating in server

    what i am missing…..

  • The topic ‘drag & drop re arrange menu items in front end page’ is closed to new replies.