How to add custom submenu links in wp-admin menus?

For the custom link into the admin menu, you need to pick up a top-level menu item by its slug and register the function using the admin_menu action hook. Here is the list of Main Admin Menu slugs. index.php => Dashboard edit.php => Posts upload.php => Media link-manager.php => Links edit.php?post_type=page => Pages edit-comments.php => … Read more

Add menu and submenu in admin with a URL instead of slug?

This is an old post but can’t you just use wordpress $menu and/or $submenu globals like Oleg suggested in number 2. When in doubt copy WordPress: wordpress/wp-admin/menu.php For example to add link this seems like it would work: function add_external_link_admin_submenu() { global $submenu; $permalink = admin_url( ‘edit-tags.php’ ).’?taxonomy=category’; $submenu[‘options-general.php’][] = array( ‘Manage’, ‘manage_options’, $permalink ); … Read more

Plugin – create a page without it appearing in the side menu

Set the parent_slug property to null, example; add_submenu_page( null // -> Set to null – will hide menu link , ‘Page Title’ // -> Page Title , ‘Menu Title’ // -> Title that would otherwise appear in the menu , ‘administrator’ // -> Capability level , ‘menu_handle’ // -> Still accessible via admin.php?page=menu_handle , ‘page_callback’ … Read more

Add an admin page, but don’t show it on the admin menu

Use a submenu page as parent slug. The admin menu has just two levels, so the imaginary third level will be hidden. Sample code, tested: add_action( ‘admin_menu’, ‘wpse_73622_register_hidden_page’ ); function wpse_73622_register_hidden_page() { add_submenu_page( ‘options-writing.php’, ‘Hidden!’, ‘Hidden!’, ‘exists’, ‘wpse_73622’, ‘wpse_73622_render_hidden_page’ ); # /wp-admin/admin.php?page=wpse_73622 } function wpse_73622_render_hidden_page() { echo ‘<p>hello world</p>’; }

Check if add_menu_page exists or not

You can use the fourth parameter of add_menu_page(), the my_unique_slug, to check if the page exists: if ( empty ( $GLOBALS[‘admin_page_hooks’][‘my_unique_slug’] ) ) add_menu_page( ‘Page Title’, ‘Top Menu Title’, ‘manage_options’, ‘my_unique_slug’, ‘my_magic_function’ ); $GLOBALS[‘admin_page_hooks’] is the list of registered pages.

How to Add a Sub Menu Page to a Custom Post Type?

add_options_page() automatically adds it underneath settings, however add_submenu_page() gives you control as to where you want it to show up. Try something like this: add_submenu_page( ‘edit.php?post_type=portfolios’, __( ‘Test Settings’, ‘menu-test’ ), __( ‘Test Settings’, ‘menu-test’ ), ‘manage_options’, ‘testsettings’, ‘mt_settings_page’ );

add_menu_page() with different name for first submenu item

You can make the ‘slug’ for the submenu page equal that of the top level page, and they’ll point to the same place: add_action(‘admin_menu’, ‘my_menu_pages’); function my_menu_pages(){ add_menu_page(‘My Page Title’, ‘My Menu Title’, ‘manage_options’, ‘my-menu’, ‘my_menu_output’ ); add_submenu_page(‘my-menu’, ‘Submenu Page Title’, ‘Whatever You Want’, ‘manage_options’, ‘my-menu’ ); add_submenu_page(‘my-menu’, ‘Submenu Page Title2’, ‘Whatever You Want2’, ‘manage_options’, … Read more