//Adding an Options Page in WordPress Settings Menu

Adding an Options Page in WordPress Settings Menu

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)
By |2017-07-07T23:52:26+00:00July 7th, 2017|Categories: How To|Tags: , |0 Comments

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

We use cookies on this site to improve our service, perform analytics and remember website preference. By using the site, you consent to these cookies. I consent to cookies