I’m working on adding a settings page for my first plugin. When you’re just starting off, it’s complex. One of the things I found confusing was the difference between these three functions:
- add_options_page
- add_menu_page
- add_submenu_page
So here’s the difference:
add_options_page
Creates a menu under the Settings menu, which is what you would want for a plugin settings page. This is a convenience function that simply calls add_submenu_page with a first parameters of ‘options-general.php’. Using this function or add_submenu_page are equally acceptable.
add_menu_page
This adds a first level menu item. This menu will be at the same level as Appearance, Plugins, Users, Tools, Settings, etc. It will by default show up at the bottom of the other menus with a separator in between. If you’re writing a plugin, this is not what you’re looking for.
add_submenu_page
This is used to a sub menu to any existing menu. You can use add_options_page or other convenience functions that will just call this function with the first parameter provided for you. To add a submenu to the Settings menu, which is what you want if you’re writing a plugin, pass ‘options-general.php’ as the first parameter. This is exactly what add_options_page does.
Submit a Comment