Reputation: 13
Hello i want help in this code
`add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page(){ add_menu_page( 'custom menu title', 'custom menu','my-menu-slug2' ,'manage_options', 'custompage', 'my_custom_menu_page', plugins_url( 'myplugin/images/icon.png'
), 8 );
//add_submenu_page("my-menu-slug2", "My Submenu", "My Submenu", 0, "my-submenu-slug", "mySubmenuPageFunction");
//add_submenu_page("my-menu-slug2", "My Submenu2", "My Submenu2", 0, "my-submenu-slug", "mySubmenuPageFunction");
}`
function my_custom_menu_page(){
echo "Admin Page Test";
}
when i add "my-menu-slug2" in add-menu-page the menu will disappear and i want to add sub pages. ere in sub menu a parameter is 0 after sub menu name "My Submenu2" if add it in main menu then it will appear but the position will not work it will appear in the bottom can anyone please help
Upvotes: 1
Views: 83
Reputation: 1091
Try This:
add_menu_page('My Custom Page', 'My Custom Page', 'manage_options', 'my-top-level-slug');
add_submenu_page( 'my-top-level-slug', 'My Custom Page', 'My Custom Page', 'manage_options', 'my-top-level-slug', 'mySubmenuPageFunction');
add_submenu_page( 'my-top-level-slug', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-secondary-slug', 'mySubmenuPageFunction');
Reference: http://codex.wordpress.org/Function_Reference/add_submenu_page
Upvotes: 0