admin管理员组

文章数量:1122826

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);

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);
Share Improve this question asked Mar 14, 2017 at 8:53 ThomGOThomGO 414 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0
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/

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.

本文标签: WordPress Plugin menu position overwrite other item