Anatomy Of A WordPress Plugin: Adding Admin Menu For Options Page

[featured-image]All but the most simple of WordPress plugins will require an options page in the Admin area which will need to be made accessible to the admin users. The main way this would be done is to add an entry to the admin menu.

This is done using the add_action function with the admin_menu hook to call a custom function.

This custom function then uses the add_options_page function to add the options page to the Settings menu.

The code below is from my RSS Suffix plugin where a menu option called azurecurve RSS Suffix is calling a function called azc_rss_config_page:

add_action( 'admin_menu', 'azc_rss_settings_menu' );

function azc_rss_settings_menu() {
	add_options_page( 'azurecurve RSS Suffix'
						,'azurecurve RSS Suffix'
						, 'azc_rss_config_page' );

The structure of the add_options_page function is as follows:

add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function);
  • $page_title – is the text to be displayed in the title tags of the page when the menu is selected.
  • $menu_title – the text to be used for the menu.
  • $capability – the capability required for this menu to be displayed to the user; for a settings page to be displayed to users who will maintain settings, this should be set to manage_options.
  • $menu_slug – the slug name to refer to this menu by (should be unique for this menu).
  • $function – the function to be called to output the content for this page.


Leave a Reply

Your email address will not be published. Required fields are marked *