i've got a question. I created a plugin with a menu and i want to show this under the Dashboard menu-item. In some of my wordpress installations the dashboard item will be overwrited. How can i fix this?

My code to add the menu is:

add_menu_page('pluginname', 'pluginname', 'manage_options', 'pluginname-hello', '', 'dashicons-admin-site', 2);

2 Answers 2

add_submenu_page('index.php', __('Plugin Name from page', 'pluginname'), 'Plugin Name', 'manage_options', 'pluginname-hello', 'you_call_function' );

pluginname-hello - The slug name to refer to this menu by (should be unique for this menu).

you_call_function - The function to be called to output the content for this page.

More information: https://developer.wordpress.org/reference/functions/add_submenu_page/

  • I've done this correctly, but i want to place the plugin-menu beneath the Dashboard without overwriting other menu items.
    – ThomGO
    Mar 14, 2017 at 9:10

The code must be work. Add the code in functions.php and check result.

function admin_menu(){
    add_menu_page('pluginname', 'pluginname', 'manage_options', 'pluginname-hello', '', 'dashicons-admin-site', 2);

add_action('admin_menu', 'admin_menu', 99);
//add_action('admin_menu', array($this, 'admin_menu'), 99); //for class based.

If you face the problem further change the priority of admin_menu hook like 99 to 1 or 2 as per your need.

  • Thanks this works! I've added: add_action('admin_menu', 'pluginname_menu', 99); And now it doesnt overwrite another menu item :)
    – ThomGO
    Mar 14, 2017 at 9:14
  • Btw, on some installations i still overwrite Dashboard.. :(
    – ThomGO
    Mar 14, 2017 at 9:17
  • Explain a little bit or can you give screenshots. :) Mar 14, 2017 at 9:27
  • I can't screenshot ATM, but the dashboard is on position 2 in the menu. When i install the Plugin it will totally overwrite the dashboard menu item, i dont want this as result: The Dashboard is not showing anymore.. I want the plugin to be under the dashboard menu item.
    – ThomGO
    Mar 14, 2017 at 9:29
  • global $menu; print_r($menu); check your menu position. By the by the dashboard menu default position is 2 so you use you plugin position 3. "When I install the Plugin" which plugin you mention.. your custom plugin or any community plugin.Then tell me the plugin name. Hope i will give you exact solution. Mar 14, 2017 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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