最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

display link to a custom plugin in admin menu bar

programmeradmin0浏览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');

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
Add a comment  | 

2 Answers 2

Reset to default 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 );
}

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 );
}
发布评论

评论列表(0)

  1. 暂无评论