What you are searching for its a submenu page. Try with this:
add_submenu_page( 'my-top-level-slug',
'My Custom Submenu Page',
'My Custom Submenu Page',
'manage_options',
'my-secondary-slug'
);
you can find more info here
An example with your code:
function my_plugins() {
add_menu_page(
'My Plugin',
'My Plugin',
'manage_options',
'visitor-counter-by-funcion', //THIS IS THE SLUG YOU NEED TO USE IN YOUR SUBMENU ITEMS
'my_custom_menu_page',
'dashicons-chart-bar'
);
add_submenu_page(
'visitor-counter-by-funcion', //THIS IS THE SLUG OF YOUR PARENT MENU PAGE
'My Custom Submenu Page',
'My Custom Submenu Page',
'manage_options',
'my-secondary-slug',
'my_custom_sub_menu_page'
);
}
add_action('admin_menu', 'my_plugins');
/**
* Display a custom menu page
*/
function my_custom_menu_page() {
esc_html_e('Admin Page Test', 'textdomain');
}
/**
* Display callback for the submenu page.
*/
function my_custom_sub_menu_page() {
?>
<div class="wrap">
<h1><?php _e('My Custom Submenu Page', 'textdomain'); ?></h1>
<p><?php _e('My Custom Submenu Page', 'textdomain'); ?></p>
</div>
<?php
}
its looking like this: