Create Plugin Options Page Under Admins Settings Menu

Once you’ve created  a very basic plugin consisting of the minimum 2 files, you may want to add a options page.

This tutorial assumes you’ve already create your plugin and ads a single page which is linked from under the main Settings tab in the standard WordPress dashboard installation for admins.

A very basic plugin will only include the following:

  • plugins.php or functions.php (you could use either)
  • readme.txt file
  • optional header banner image for your plugins page on WordPress.org

Once you’ve tested your plugins for bugs on a local installation, you can submit it to the WordPress plugins repository using a subversion client.

Code for Options Page

Here’s some very basic code you can use to create your own plugin options page with a link under Settings.

You can paste this code into your main plugins php file or create a separate options.php file. This is what i have chosen to do and placed this options.php file in a new Includes folder.

Here’s the code on pastebin

You can change the html which is something i will be writing about soon.

Options.php or Plugin.php

Personally, i think its better to create a new file for your plugins settings page. This way its easier to find and better organized.

If you do make a new file named options.php, you’ll need to include it in your main plugin php file.

There’s 2 functions you can use to do this.

Using Require or Include?

If you’ve been digging around in plugin files for awhile, you’ve probably seen code like require once or includes.

  1. require – This produces a fatal error if there’s problem in the file which results in the script failing to execute
  2. includes – This produces a warning and allows the script to continue processing

Here’s the code you can choose from which should be places in your main plugins.php or functions.php file:

//Require
require 'includes/options.php';

//Includes
includes 'includes/options.php';

You could simply create an options.php for your settings page code or create a folder which i have done named includes and placed the options.php in there.

More Options

Plugin Options Page WordPressThis clearly is one of the most basic ways to create a link under Settings in the WordPress dashboard for your plugins options page.

There’s other ways to do this so your options page matches the default WordPress style and appearance.

This is what i will be writing about next time i develop my plugins working copy.

I’ll be showing you how to use code from an existing plugin to make an awesome options page which you can easily customize.

Note: At some stage you’ll experience fatal errors when editing and developing your plugin files locally. Always create unique function names which are also descriptive but will never conflict with the WordPress core function names.

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.