[Plugin] Getting an extra sub menu item in my plugin menu
-
I’m having a weird problem with a menu I’m adding to the administration interface.
I keep getting an unwanted sub menu item.
I have the follwoing code:add_action('admin_menu', 'sl_menu'); function sl_menu() { if (function_exists('add_menu_page')) { add_menu_page('Menu title','Menu title', 'manage_options', 'my-pluging-folder/my_plugin.php', '', ''); } if (function_exists('add_submenu_page')) { add_submenu_page('my-pluging-folder/my_plugin.php', 'Sub menu title', 'Sub menu title', 'manage_options', 'my-pluging-folder/some_file.php'); } }
The result is:
Menu Tile
– Menu Title
– Sub menu titleAs you can see, the main page / menu tile is also shown as a sub menu item.
Why is that?
If I take “the same” code from Lester Chans plugin ‘wp-polls’, I only get the main menu item + one sub menu item:
### Function: Poll Administration Menu add_action('admin_menu', 'poll_menu'); function poll_menu() { if (function_exists('add_menu_page')) { add_menu_page(__('Polls', 'wp-polls'), __('Polls', 'wp-polls'), 'manage_polls', 'wp-polls/polls-manager.php', '', plugins_url('wp-polls/images/poll.png')); } if (function_exists('add_submenu_page')) { add_submenu_page('wp-polls/polls-manager.php', __('Manage Polls', 'wp-polls'), __('Manage Polls', 'wp-polls'), 'manage_polls', 'wp-polls/polls-manager.php'); } }
Now, why does this work?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘[Plugin] Getting an extra sub menu item in my plugin menu’ is closed to new replies.