1

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'
    );

2 Answers 2

1

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.

1
  • wrap the function add_theme_page() inside a function and hook the wrapper function to admin_menu action hook. add_action('admin_menu', 'add_theme_page_wrapper_function'); Nov 23, 2015 at 16:37
1

Use add_submenu_page()

It uses pretty much the same structure, but takes the parent-menu slug or file name as the first argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.