[wp-hackers] Creating an options sub-submenu

Jennifer Hodgdon yahgrp at poplarware.com
Mon Jun 25 16:53:04 GMT 2007


Lutz Schroeer wrote:
> Hi,
> 
> I'm writing a plugin which has many, many options. To put all these 
> options onto a single page would result in a confusingly complex 
> interface. So I have the idea to split the options into various sub-pages:

It's actually fairly straightforward to do this, and WP does have the 
mechanism built in. You simply use add_menu_page to add the top-level 
menu, and then add_submenu_page to add submenus to it. Function args 
are described in:

http://codex.wordpress.org/Adding_Administration_Menus

Here's an example:

// top-level menu -- note that
add_menu_page( 'Main Menu Title', 'Main Menu Title', 
'required_capability_or_role', 'plugin_file.php, 'main_menu_function' );

   // sub-menus

add_submenu_page( 'plugin_file.php', 'Submenu Title 1',
'Submenu Title 1', 'required_capability', 'plugin_file.php', 
'submenu_1_function' );

// etc.

     --Jennifer


More information about the wp-hackers mailing list