How to add Theme options in wordpress Theme

How can we add a custom theme option panel in Wordpress.



It can be done with two ways
1. with using Plugin.
2. Integrate Plugin files with theme

Lets see How to make it with Plugin

First of all download option tree plugin from here
http://wordpress.org/extend/plugins/option-tree/

Install the plugin and Activate it.

Now you can see the option tree in admin menu , goto Option Tree -> Setting

Here you can add a Section and Setting as you want.

There are many input type for eg. Text box for Text , upload for selecting the image, background , color and many more.

You have to give unique id to every option.then you can access this value with id.

For access the Value You can use Following PHP Code.

Value Access Code


<?php 
     if ( function_exists( 'get_option_tree') )
    {
     echo get_option_tree( 'sliderimage1' );
    }
?>

OR

<?php  echo get_option_tree( 'sliderimage1' ); ?>

By this code you can fetch the value of option. Here sliderimage1 is id of option.

Using this code i can get the SRC of Image wich is Selected From option Panel.

After Saving the Setting you can see this option panel at Appereance -> Theme Option

If you are more familiar with php you can also integrate this plugin in your theme files.For that you have to follow just simple steps wich is shown in Option Tree's Documentation.



Comments