Solution:
Try the code below in your functions.php file. It should work correctly.
add_menu_page(
'Menu Page Title', // page title
'Menu Menu Text', // menu link text
'manage_options', // capability to access the page
'menu_slug', // page URL slug
'menu_callback_function', // callback function to display the content on options page
'dashicons-format-status', // menu icon
2 // priority
);
add_submenu_page(
'menu_slug', // page URL slug
'Sub Menu Title', // page title
'Sub Menu Text', // menu link text
'manage_options', // capability to access the page
'submenu_slug', // page URL slug
'submenu_callback_function', // callback function to display the content on options page
1 // priority
);
function menu_callback_function(){
echo "This is menu page...";
}
function submenu_callback_function(){
echo "This is submenu page...";
}