i have a custom plugin and i want the link to the plugin be accessible in the admin menu bar of the wp-admin
right now, im using below code. but the link to this shows under my settings. what hook should i replace with the add_option_page
?
function custom_plugin() {
add_options_page("my plugin", "plugin settings", 1, "my plugin", "custom_function");
}
add_action ('admin_menu', 'custom_plugin');
i have a custom plugin and i want the link to the plugin be accessible in the admin menu bar of the wp-admin
right now, im using below code. but the link to this shows under my settings. what hook should i replace with the add_option_page
?
function custom_plugin() {
add_options_page("my plugin", "plugin settings", 1, "my plugin", "custom_function");
}
add_action ('admin_menu', 'custom_plugin');
Share
Improve this question
asked Sep 8, 2013 at 3:16
user1933824user1933824
7112 gold badges7 silver badges9 bronze badges
2 Answers
Reset to default 1if you want to add a top level menu page then you need to use add_menu_page()
function more details on codex
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page(){
add_menu_page( 'my plugin', 'plugin settings', 'manage_options', 'my-plugin-settings', 'my_plugin_custom_function', plugins_url( 'myplugin/images/icon.png' ), 66 );
}
See this:
basic structure is:
add_menu_page( $page_title, $menu_title, $capability, $menu_slug,
$function, $icon_url, $position );
See example
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page() {
add_menu_page( 'Custom Menu Page Title', 'Custom Menu Page', 'manage_options', 'custom.php', '', 'dashicons-welcome-widgets-menus', 90 );
}