0

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

2 Answers 2

1

if 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 );
}
0

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

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.