Show nav-menus.php on custom menu page

Hi there,

I've made a custom administration menu button called 'Menu' (with position 24, between Pages and Comments). I want that my users can change their menus there instead of under Appearance --> Menus. Is there a way to do this without having to update the code every time WordPress releases a new version (so not copy the nav-menu.php and paste it)?

I'm sorry for my bad explanation, my English is not very good, but i'm working on that :wink:.

Thanks

Marijn

  • Alexander
    • DEV MAN’s Mascot

    Hi @Marijn,

    I've not tested this, but when you add that menu item with your custom code try setting this as the page it pulls up:

    "nav-menus.php"

    That should effectively link the existing page to your new menu item. I've done this for other items successfully. Let me know if this works for you, if not I can look into it further.

    Best regards

  • Marijn
    • Design Lord, Child of Thor

    Hi Alexander,

    Thanks for your response.

    Could you paste the code here that you used to make this work? I've tried to pull the other page up within an iframe, used include("nav-menu.php"); and other methods such as get_page( $page_id ), but I can't find the right solution.

    Thanks!

    Marijn

  • Alexander
    • DEV MAN’s Mascot

    Sure, here you go!

    add_action('admin_init','move_menus_menu_item');
    
    function move_menus_menu_item(){
    	remove_submenu_page( 'themes.php', 'nav-menus.php' );
      add_menu_page( 'Menus', 'Menus','edit_theme_options', 'nav-menus.php','','',10);
    }

    Just include this in a plugin, or your theme's functions.php

    First it removes the existing menu page that is usually in the "Themes" submenu. Then it adds it back to the admin menu as a root level item.

    Hope this helps! Let me know how it goes getting it setup.

    Best regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.