wordpress - top level menu item is also being displayed as sub-menu item -


i new wordpress development. trying create plugin top-level menu item being displayed sub-menu item.below code.

<?php /* plugin name: rooties_main_menu */ add_action('admin_menu', 'gpwp_rooties_create_menu'); function gpwp_rooties_create_menu() { add_menu_page('my rooties setting','rooties settings', 'manage_options', __file__, 'gpwp_rooties_setting_page',plugins_url('/images/wordpress.png',__file__) );  add_submenu_page(__file__, 'about rooties plugin', 'about', 'manage_options',__file__.'_about',gpwp_rooties_setting_about_page); add_submenu_page(__file__, 'today\'s menu', 'today\'s menu', 'manage_options',__file__.'_about',gpwp_rooties_setting_menu_form_page);    } ?> 

i know not best code per security prospects. trying these @ local system.

as per above code "about" , "today's menu" should displayed sub-menu displaying "rooties settings" too. please let me know wrong.

from codex: http://codex.wordpress.org/adding_administration_menus#using_add_submenu_page

for existing wordpress menus, php file handles display of menu page content. submenus of custom top-level menu, unique identifier sub-menu page.

in situations plugin creating own top-level menu, first submenu have same link title top-level menu , hence link duplicated. duplicate link title can avoided calling add_submenu_page function first time parent_slug , menu_slug parameters being given same value.

there code examples here, although old -> http://wordpress.org/support/topic/add_menu_page-always-add-an-extra-subpage

before:

add_menu_page('section', 'section', 10, __file__, 'section'); add_submenu_page(__file__, 'edit', 'edit', 10, 'section-edit', 'section_edit'); 

fixed:

add_menu_page('section', 'section', 10, __file__, 'section'); add_submenu_page(__file__, 'edit', 'edit', 10, __file__, 'section_edit'); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -