WordPress -- Add Admin Options

This tutorial is for developers who want to add additional options in the Wordpress Admin panel. As an example, suppose you want a disclaimer text to be placed in the footer of each of the blog pages. Sure, you can hard-code the text in the footer.php template file. But a better option is to add an option available in Admin control panel where the admin can go in and change and save the disclaimer text.

In this example, we will add a submenu called "Disclaimer Options" under "Admin -> Options". On this Disclamier Options page will a textarea field where the admin can type in the disclaimer text. When the admin updates this option, the text change will be reflected in the footer.

This is implemented as a plug in with a single file called disclaimertext.php...

add admin option

And then in the theme footer.php file, you place the code ...

<?php echo get_option('disclaimertext'); ?>

where you want the disclaimer text to be displayed. That is how you retrieve an option.

The general idea on how to create a plug in is in referenced here which explains the standard comment header that makes wordpress recoginze your plugin when you place the file in wp-content/plugins . The file can be in that directory by itself. Or preferably, is can be in its own sub-folder.

The form that you would write out into the newly constructed option page is explain here.

 

 

 

 

main content here