The link you provided has the answer, given by Otto as a comment:
Short answer is that you can’t. Not only using add_menu_page like
that. Those icons WordPress uses are added as background images via
CSS, not using theicon_url
method that is provided with
add_menu_page
.
As you said the syntax is:
syntax: add_menu_page( $page_title*, $menu_title*, $capability*, $menu_slug*, $function, $icon_url, $position ); – * required
So I used my custom icon (home.png
), placed in a folder (/my_theme/admin/images/
) as:
add_menu_page(
'Site Options', // The title to be displayed on the corresponding page for this menu
'Site Options', // The text to be displayed for this actual menu item
'manage_options', // Which type of users can see this menu
'sandbox', // The unique ID - that is, the slug - for this menu item
'sandbox_menu_page_display', // The name of the function to call when rendering the menu for this page
get_bloginfo( template_directory ) . '/admin/images/home.png' // Icon for the Main menu in Admin panel
);