Here is a piece of working code i used for my project. i placed this code in a file residing within 'lib' folder. you can also write in your functions file.
$themename = "Ondeweb";
$shortname = "odwb";
$position = '63.3';
$file_dir=get_bloginfo('template_directory');
$icon = $file_dir."/images/wand.png";
add_menu_page($themename, $themename, 'administrator', 'ondeweb-now', 'ondeweb_admin', $icon, $position);
}
function innUbud_add_subpage() {
add_submenu_page(
'ondeweb-now'
, 'Ads List'
, 'Advertisement List'
, 'manage_options'
, 'ondeweb-now-advertise'
, 'advertiseList'
);
add_submenu_page(
'ondeweb-now'
, 'Home page videos'
, 'Home page videos'
, 'manage_options'
, 'ondeweb-now-videos'
, 'videoList'
);
}
function advertiseList() {
require_once( get_template_directory() . '/lib/advertise.php' );
}
function videoList() {
require_once( get_template_directory() . '/lib/videos.php' );
}
in the above code, 'ondeweb-now' is the slug for parent menu which is the indication of parent menu for the sub-menus slug (ondeweb-now-advertise & ondeweb-now-videos)
for detailed explanation these are right places to be:- add_menu_page & add_submenu_page