My theme currently has a single menu on the left hand sidebar of WP admin. I want to include submenus on that menu.
How can I add, for example, a single submenu item to the “Theme Options” menu below?
add_menu_page(
"My Theme Options",
"Theme Options",
'edit_themes',
basename(__FILE__),
'my_admin',
get_bloginfo('template_directory') .'/img/favicon.png'
);
To do that, you would use
add_submenu_page()
.But I would strongly recommend against making submenu pages for Theme options. To begin with, you should be using
add_theme_page()
for your Theme options page, so that your Theme options page itself is properly placed as an Appearance sub-menu page.Use add_submenu_page()
It uses pretty much the same structure, but takes the parent-menu slug or file name as the first argument.