When you want to add an options page in WordPress, you need to use function add_options_page. This example will create one page containing a simple sting:

add_action( 'admin_menu', 'my_menu' );

function my_menu() {
		'Menu Title',
		'Page Title',

function callback_fn()
	echo "Some text";

First part of the example adds an action to call a function for creating our menu page. This action is called admin_menu. In action callback we add function add_options_page. This function has 5 parameters:

  1. Title in WordPress menu
  2. Page title (Title display by browser)
  3. User capabilities (we use “manage_option“)
  4. Page slug (URL in browser)
  5. Callback function of our page (this function is called, when the page is displayed, it contains all of the source code for the page and in our case is just a simple string)

Was this article helpful?