How To Create An Options Page For Your WordPress Theme

Posted in WordPress4 years ago • Written by 42 Comments

WordPress is one of the most popular Content Management Systems. Also WordPress is a CMS of choice for many web developers It’s relatively easy to use, but can be made even simpler when you include an administration panel for users when making themes. Additionally, themes buyers find the options panel too easy to use rather than having to open up the PHP template files and fiddling with the code.

Today we will be incorporating an options panel for the WordPress Classic theme. The methods you will learn will allow you to very easily integrate it into an existing theme you’re working on.

Setting The Files :

The theme that we will be working on is the classic theme provided by wordpress. You can find it on wp-content/themes folder. You should see the following files:

  • index.php
  • functions.php
  • comments.php
  • footer.php
  • header.php
  • rtl.php
  • sidebar.php
  • style.css
  • screenshot.png
  • An images folder with two files

Most of our work will be done within the functions.php file.

Now go to your wordpress admin panel then go to Appearance>Themes  and activate the classic theme.

Working on functions.php :

Begin by opening up functions.php in your code editor of the classic theme ( wp-content/themes/classic/functions.php ) then insert the following code :

<?php
$themename = "Classic Theme";
$shortname = "ct";

I added two variables the first one reffers to the name of the theme and the second is the shortname : You can choose any name for these two variables but don’t forget to select significant names because you will be using them later.

Now let’s start adding some options for our theme :

$options = array (
    array( "name" => $themename." Options",
           "type" => "title"),
    array( "type" => "open"),
    array( "name" => "Color Scheme",
           "desc" => "Select the color scheme for the theme",
           "id" => $shortname."_color_scheme",
           "type" => "select",
           "options" => array("blue", "red", "green"),
           "std" => "blue"),
    array( "name" => "Logo URL",
           "desc" => "Enter the link to your logo image",
           "id" => $shortname."_logo",
           "type" => "text",
           "std" => ""),
    array( "name" => "Homepage header image",
           "desc" => "Enter the link to an image used for the homepage header.",
           "id" => $shortname."_header_img",
           "type" => "text",
           "std" => ""),
    array( "name" => "Footer copyright text",
           "desc" => "Enter text used in the right side of the footer. It can be HTML",
           "id" => $shortname."_footer_text",
           "type" => "text",
           "std" => ""),
    array( "name" => "Google Analytics Code",
           "desc" => "Paste your Google Analytics or other tracking code in this box.",
           "id" => $shortname."_ga_code",
           "type" => "textarea",
           "std" => ""),
    array( "name" => "Feedburner URL",
           "desc" => "Paste your Feedburner URL here to let readers see it in your website",
           "id" => $shortname."_feedburner",
           "type" => "text",
           "std" => get_bloginfo('rss2_url')),
    array( "type" => "close"));

Here the variable “option” contains a big array which also contains other child arrays. Each child array holds an option.

The first array reffers to the title of the page ( In our case it’s ‘Classic Theme Options’ ). Every time when we want to add a new option we have to declare an array with a type and give it the name we want.

You can take a look at the options specified below :

  • name: The name of the input field.
  • desc: A short description explaining what it is to the user.
  • id: the id of the field, prefixed by the shortname. It will be used to store as well as access the options.
  • type: the input type – select, text or textarea
  • options: used to declare an array of options for a select type input.
  • std: the default input value, used if no other input is given.

Now we have our options ready but how can we view them ? Add the following pieces of code to the functions.php file:

function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
foreach ($options as $value) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
header("Location: themes.php?page=functions.php&saved=true");
die;
} else if( 'reset' == $_REQUEST['action'] ) {
foreach ($options as $value) {
delete_option( $value['id'] ); }
header("Location: themes.php?page=functions.php&reset=true");
die;
}
}
add_menu_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}

Here I declared a function with a name of “mytheme_add_admin”. This function is used for updating options : If the options are saved, then all the options are updated with their new values. If the options are being reset (indicated by another hidden variable with a value reset), then all of the options are deleted. The last line adds a theme page( add_theme_page ) in Appearance box and it calls mytheme_admin function. If you want you can replace add_theme_page with add_menu_page to create an external box :

At this step we still don’t have the theme options page, so we have to write mytheme_admin function which was called by add_theme_page, add this code to functions.php :

function mytheme_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST['saved'] ) echo '<div id="message"><p><strong>'.$themename.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message"><p><strong>'.$themename.' settings reset.</strong></p></div>';
?>

Here we have some conditions : if the settings are saved WordPress will show ” Classic theme settings saved “. Likewise for reset.

Now paste the code above I will explain it after :

<div class="wrap">
<h2><?php echo $themename; ?> Settings</h2>

<form method="post">

<?php foreach ($options as $value) {
switch ( $value['type'] ) {

case "open":
?>
<table width="100%" border="0" style="background-color:#cdcdcd; padding:10px;">

<?php break;

case "close":
?>

</table><br />

<?php break;

case "title":
?>
<table width="100%" border="0" style="background-color:#868686; padding:5px 10px;"><tr>
<td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
</tr>

<?php break;

case 'text':
?>

<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" /></td>
</tr>

<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

<?php
break;

case 'textarea':
?>

<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:400px; height:200px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea></td>

</tr>

<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

<?php
break;

case 'select':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
</tr>

<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

<?php
break;

case "checkbox":
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
</td>
</tr>

<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

<?php break;

}
}
?>

<p class="submit">
<input name="save" type="submit" value="Save changes" />
<input type="hidden" name="action" value="save" />
</p>
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
</div>

Explanation :

With this code we created our options page content : I used a php foreach loop, each option type is evaluated on a case-by-case basis. So if the type of the option is title do this, if it is a checkbox do that…

If there is an “open” type option we do nothing. If there is a “close” type options, we close our table. For each of the types “text” , “select” , “checkbox” and “textarea” , we display the corresponding input. At the end we added two buttons one to save the settings and the other to reset them.

Now our options page is ready, but we have to add this short code to make it work :

<?php
}
add_action('admin_menu', 'mytheme_add_admin');
?>

This short code tells WordPress to add the admin menu.

After all this, here the result you should end up with :

In this example I used simple styles included in functions.php to make our options page looks better but I will show you how to add a stylesheet to functions.php so you can add your styles rapidly.

How to add a stylesheet to functions.php :

First, you have to create a new folder on your theme folder, name it functions then create a new css file with a name of functions.css. After flling your css file add this code to functions.php after mytheme_add_admin function :

function mytheme_add_style() {
$file_dir=get_bloginfo('template_directory');
wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
}

That adds the functions.css file to the head. The location of the file is determined by the template directory.

Also, if you want you can use scripts to make your options page better by including a js file.To do this you have to change

wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");

To :

wp_enqueue_script("script", $file_dir."/functions/script.js", false, "1.0");

After adding your stylesheet or your script, you have to add this code under add_action(‘admin_menu’, ‘mytheme_add_admin’); so they will be active :

add_action('admin_init', 'mytheme_add_init');

Making Use of the Options :

Now after creating our options, I will show you how to make use of them. First up, open up your header.php file, and add the following code:

<?php
global $options;
foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
?>

You must put the code above at the start of all the files which you add options to. Once you’ve done that you can begin using your options. For example : If you want to display the footer text you have to echo $ct_footer_text ( ct reffers to the shortname of the theme ) :

<?php
echo $ct_footer_text;
?>

For a checkbox you can check if the box is checked ( it will return true ) do this…

You can download the functions.php file here.

That’s it ! Thanks for reading this tutorial and I hope it was useful.

If you enjoyed this article, get email updates (it's free).

Join over 77,235 Subscribers Today.

22 Written Articles

42 Comments Best Comments First
  • Ravi

    Monday, August 30th, 2010 07:39

    15

    Great tutorial.
    Thank you for sharing :)

    @Scott Corgan,
    “header already sent” error is most probable because you have few empty lines in functions.php file

    remove all empty lines from functions.php file and error should be gone.

    +2
  • Konstantin

    Saturday, May 22nd, 2010 12:30

    5

    I’m sorry, but I don’t like it at all.
    Have you ever heard of WordPress’ Settings API?
    Maybe you want to get familiar with the WordPress Core before you write tutorials that … are no good.

    +1
  • Scott Corgan

    Tuesday, July 6th, 2010 19:10

    14

    Having issues with “header already sent” any ideas?

    Thanks.

    0
    • Sean Thompson

      Saturday, February 12th, 2011 01:50

      18

      Functions.php is very touchy. In PHP you cant have any blank lines. So take out any blank lines and you should be good.

      +1
  • Matt @ Theme Thesis

    Friday, May 21st, 2010 23:27

    1

    Sweeeet. It’s nice to see all these options page tutorials creeping up now. When I first learned how to do them the resources around were so scarce, it was brutal. This is very nicely written, good job!

    0
  • dev

    Monday, November 29th, 2010 10:35

    16

    great tutorial thanks :)

    0
  • Noor Mustafa

    Monday, April 4th, 2011 10:30

    19

    Thanks! I’ve been getting those errors in a couple of little websites. Now I know what the heck is going on and have written on it also

    0
  • riesurya

    Thursday, June 3rd, 2010 17:31

    13

    clearly explained tutorial. I’ll try in my next WP theme.

    0
  • Naeem

    Tuesday, May 25th, 2010 15:33

    12

    Very nice article, a must bookmark!

    0
  • Naupad

    Wednesday, July 6th, 2011 18:28

    22

    The tutorial is good but If I already have a theme options page in the parent theme and want my own customizations in the child theme, how can I create a theme options page for child theme as common functions like mytheme_add_admin would conflict with those in parent theme and raise error….

    Help….

    0
  • Auré

    Sunday, May 23rd, 2010 12:38

    6

    Interresting article, thanks for sharing :)

    0
  • Patrick Offczorz

    Saturday, May 22nd, 2010 09:04

    3

    Great Tutorial. That’s exactly what I was looking for. Thanks m8

    0
  • nay

    Saturday, May 22nd, 2010 07:38

    2

    HI fri., thanks your training and tutorials. I really got experience for your tutorials. May be you too get a lot of knowledge and share to all other peoples.

    0
  • Jean-Baptiste Jung

    Monday, May 24th, 2010 10:14

    7

    Great tutorial! I used to write a similar post one or two years ago but yours is most complete and up to date. Keep ut the great job!

    0
  • Sumeet Chawla

    Monday, May 24th, 2010 10:43

    8

    Just the thing I wanted! Thank you very much for the share… We can create very complex option pages depending on the theme I guess…

    0
  • WordPress 101

    Monday, May 24th, 2010 19:18

    11

    Great tutorial! Options pages are becoming almost required for anyone who customizes themes, or creates WordPress sites for their clients. Tweeted and shared this with my WordPress 101 members. Thanks again!

    0
  • Hein

    Monday, May 24th, 2010 15:31

    10

    Nice and helpful guide, great job. definitely going to use this ;)

    0
  • Jordan Walker

    Monday, May 24th, 2010 15:15

    9

    Great way to add customization to the administration section of wordpress for customers to update themes and other options.

    0
  • Todd

    Friday, June 3rd, 2011 12:33

    21

    So, when was this blog post written? I can’t see a time stamp anywhere so I don’t know if this is out of date or not.

    0
    • Hasitha

      Saturday, September 3rd, 2011 20:16

      26

      +1 for that.

      0
    • Rean John Uehara

      Friday, June 3rd, 2011 14:18

      20

      May 21, 2010. :|

      0
  • Ljubisa

    Sunday, December 18th, 2011 04:18

    33

    You haven’t mentioned where to paste “options page content”.
    “Now paste the code above I will explain it after :”

    0
  • Joseph

    Friday, January 6th, 2012 13:58

    37

    how to have the textarea boxes save the paragraphs and line breaks? right now I get one long line of text.

    Thanks for any help

    0
  • Joseph

    Friday, January 6th, 2012 00:05

    35

    Very simplified and easy to understand tutorial thank you very much.
    On point, when saving the textarea doesn’t save the line breaks, how can I fix this.

    0
  • Chris

    Thursday, July 14th, 2011 06:52

    23

    Thankyou sir..Created my first theme option panel today. And it looks great!

    0
  • Rick Benetti

    Tuesday, January 31st, 2012 04:18

    38

    Before $options = array (

    It’s just define $options like a global using this:
    global $options;

    0
  • Rean John Uehara

    Tuesday, January 31st, 2012 06:57

    39

    Oops, can you post that again?

    0
  • Glen

    Saturday, March 24th, 2012 10:15

    41

    hi there, I’m trying to use Textarea for Google Analytics code option. But why the result changing the code?
    From:

    ar _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-29509388-1']);
    _gaq.push(['_trackPageview']);

    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

    to

    var _gaq = _gaq || [];
    _gaq.push([\'_setAccount\', \'UA-29509388-1\']);
    _gaq.push([\'_trackPageview\']);

    (function() {
    var ga = document.createElement(\’script\’); ga.type = \’text/javascript\’; ga.async = true;
    ga.src = (\’https:\’ == document.location.protocol ? \’https://ssl\’ : \’http://www\’) + \’.google-analytics.com/ga.js\’;
    var s = document.getElementsByTagName(\’script\’)[0]; s.parentNode.insertBefore(ga, s);
    })();

    0
    • Ariful H Bhuiyan

      Tuesday, May 1st, 2012 14:30

      42

      Hi.. I am having the same problem as G+ Info.. When I put Google Analytics script, it add some \ in many places. how to solve this please?

      0
  • Mike Mackintosh

    Thursday, March 8th, 2012 16:54

    40

    just stumbled upon this taking a stab at wp themes. this is a great point of reference for a wp theme/widget noob.

    Thanks!!!!

    0
  • Octavian Ristea

    Tuesday, January 3rd, 2012 16:08

    34

    Just like Chris said I would also like to know about how to do those color options. THX

    0
  • James

    Wednesday, August 17th, 2011 00:55

    25

    So much better than other tutorials on how to do this. Yours is more organized and easier the read. Thank you. ^^

    0
  • James

    Tuesday, August 16th, 2011 19:51

    24

    I was trying to follow this tutorial and let me just tell you that yours is far superior. It’s easier to read and understand and much easier/quicker to follow the steps. Had this up and running in like 30 mins. I spend my entire day yesterday trying to figure out that nutjobs tutorial. Thank you, so much.

    0
  • Roman

    Thursday, December 15th, 2011 23:31

    32

    Really nice tutorial. It was easy to understand how to make options page in WP.
    Thank you!

    -1
  • Alex

    Sunday, October 9th, 2011 20:16

    28

    Thanks for the tip. It really helped me to understand how to make a powerfull options page in wordpress.

    Thanks,
    Alex

    -1
  • Burke

    Saturday, September 3rd, 2011 23:23

    27

    Thanks so much. I followed this tutorial a few months back and it worked fine. Now when I save the options, they save, but I get the message on a white next page:

    “You do not have sufficient permissions to access this page.”

    How do I stop this from happening?

    -1
    • Joseph

      Thursday, January 5th, 2012 22:46

      36

      I fixed this by editing the two instants of header where it says
      header(“Location: themes.php?page=functions.php&saved=true”);

      to point to you page URL, in my case:
      header(“Location: admin.php?page=admin-options-page.php&saved=true”);

      -1
  • Alexander Theis

    Thursday, January 6th, 2011 09:57

    17

    Hi this is a really nice guide. But i have following problem.
    If I click on Save or Reset i will get an error.
    “Warning: Cannot modify header information – headers already sent by… ”

    Does anybody know something about it? Error is in this line
    “header(“Location: themes.php?page=functions.php&saved=true”);”
    “header(“Location: themes.php?page=functions.php&reset=true”);

    -1
  • Chris Raymond

    Friday, December 9th, 2011 17:41

    31

    I see a lot of premium themes now enable you to select from an array of background color AND texture options.

    Does anyone know what php to use to create that set of options? I’ve looked at some of these themes’ css files and they list a whole bunch of different classes for the background textures, so I am assuming a custom options panel somehow creates an array and then takes the value the user selected and generates that class name in the markup, but I would sure like to get specific php code snippets to do that.

    BTW: I am a designer who knows enough about php to be dangerous, so if you know how to do the above, please keep in mind to simplify your explanation for the non-programmer. TIA!

    -1
  • james carter

    Tuesday, October 11th, 2011 05:11

    30

    sorry. I fixed the problem. for some reason i had php that was setting up custom sidebars and menu above your code. I switched it to be below and everything worked. I have much to learn about php. :)

    -1
  • James Carter

    Tuesday, October 11th, 2011 05:05

    29

    I have been receiving this error message when clicking the save button. any ideas Warning: Cannot modify header information – headers already sent by? thanks good tutorial.

    -1
  • Mike Smith

    Saturday, May 22nd, 2010 05:11

    4

    Nice tutorial. I’m definitely going to have to try using these codes and tweaking them to fit my needs. Thanks for posting this up.

    -3
  • Glen

    Saturday, March 24th, 2012 10:15

    41

    hi there, I’m trying to use Textarea for Google Analytics code option. But why the result changing the code?
    From:

    ar _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-29509388-1']);
    _gaq.push(['_trackPageview']);

    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

    to

    var _gaq = _gaq || [];
    _gaq.push([\'_setAccount\', \'UA-29509388-1\']);
    _gaq.push([\'_trackPageview\']);

    (function() {
    var ga = document.createElement(\’script\’); ga.type = \’text/javascript\’; ga.async = true;
    ga.src = (\’https:\’ == document.location.protocol ? \’https://ssl\’ : \’http://www\’) + \’.google-analytics.com/ga.js\’;
    var s = document.getElementsByTagName(\’script\’)[0]; s.parentNode.insertBefore(ga, s);
    })();

    0
    • Ariful H Bhuiyan

      Tuesday, May 1st, 2012 14:30

      42

      Hi.. I am having the same problem as G+ Info.. When I put Google Analytics script, it add some \ in many places. how to solve this please?

      0
  • Mike Mackintosh

    Thursday, March 8th, 2012 16:54

    40

    just stumbled upon this taking a stab at wp themes. this is a great point of reference for a wp theme/widget noob.

    Thanks!!!!

    0
  • Rean John Uehara

    Tuesday, January 31st, 2012 06:57

    39

    Oops, can you post that again?

    0
  • Rick Benetti

    Tuesday, January 31st, 2012 04:18

    38

    Before $options = array (

    It’s just define $options like a global using this:
    global $options;

    0
  • Joseph

    Friday, January 6th, 2012 13:58

    37

    how to have the textarea boxes save the paragraphs and line breaks? right now I get one long line of text.

    Thanks for any help

    0
  • Joseph

    Friday, January 6th, 2012 00:05

    35

    Very simplified and easy to understand tutorial thank you very much.
    On point, when saving the textarea doesn’t save the line breaks, how can I fix this.

    0
  • Octavian Ristea

    Tuesday, January 3rd, 2012 16:08

    34

    Just like Chris said I would also like to know about how to do those color options. THX

    0
  • Ljubisa

    Sunday, December 18th, 2011 04:18

    33

    You haven’t mentioned where to paste “options page content”.
    “Now paste the code above I will explain it after :”

    0
  • Roman

    Thursday, December 15th, 2011 23:31

    32

    Really nice tutorial. It was easy to understand how to make options page in WP.
    Thank you!

    -1
  • Chris Raymond

    Friday, December 9th, 2011 17:41

    31

    I see a lot of premium themes now enable you to select from an array of background color AND texture options.

    Does anyone know what php to use to create that set of options? I’ve looked at some of these themes’ css files and they list a whole bunch of different classes for the background textures, so I am assuming a custom options panel somehow creates an array and then takes the value the user selected and generates that class name in the markup, but I would sure like to get specific php code snippets to do that.

    BTW: I am a designer who knows enough about php to be dangerous, so if you know how to do the above, please keep in mind to simplify your explanation for the non-programmer. TIA!

    -1
  • james carter

    Tuesday, October 11th, 2011 05:11

    30

    sorry. I fixed the problem. for some reason i had php that was setting up custom sidebars and menu above your code. I switched it to be below and everything worked. I have much to learn about php. :)

    -1
  • James Carter

    Tuesday, October 11th, 2011 05:05

    29

    I have been receiving this error message when clicking the save button. any ideas Warning: Cannot modify header information – headers already sent by? thanks good tutorial.

    -1
  • Alex

    Sunday, October 9th, 2011 20:16

    28

    Thanks for the tip. It really helped me to understand how to make a powerfull options page in wordpress.

    Thanks,
    Alex

    -1
  • Burke

    Saturday, September 3rd, 2011 23:23

    27

    Thanks so much. I followed this tutorial a few months back and it worked fine. Now when I save the options, they save, but I get the message on a white next page:

    “You do not have sufficient permissions to access this page.”

    How do I stop this from happening?

    -1
    • Joseph

      Thursday, January 5th, 2012 22:46

      36

      I fixed this by editing the two instants of header where it says
      header(“Location: themes.php?page=functions.php&saved=true”);

      to point to you page URL, in my case:
      header(“Location: admin.php?page=admin-options-page.php&saved=true”);

      -1
  • James

    Wednesday, August 17th, 2011 00:55

    25

    So much better than other tutorials on how to do this. Yours is more organized and easier the read. Thank you. ^^

    0
  • James

    Tuesday, August 16th, 2011 19:51

    24

    I was trying to follow this tutorial and let me just tell you that yours is far superior. It’s easier to read and understand and much easier/quicker to follow the steps. Had this up and running in like 30 mins. I spend my entire day yesterday trying to figure out that nutjobs tutorial. Thank you, so much.

    0
  • Chris

    Thursday, July 14th, 2011 06:52

    23

    Thankyou sir..Created my first theme option panel today. And it looks great!

    0
  • Naupad

    Wednesday, July 6th, 2011 18:28

    22

    The tutorial is good but If I already have a theme options page in the parent theme and want my own customizations in the child theme, how can I create a theme options page for child theme as common functions like mytheme_add_admin would conflict with those in parent theme and raise error….

    Help….

    0
  • Todd

    Friday, June 3rd, 2011 12:33

    21

    So, when was this blog post written? I can’t see a time stamp anywhere so I don’t know if this is out of date or not.

    0
    • Rean John Uehara

      Friday, June 3rd, 2011 14:18

      20

      May 21, 2010. :|

      0
    • Hasitha

      Saturday, September 3rd, 2011 20:16

      26

      +1 for that.

      0
  • Noor Mustafa

    Monday, April 4th, 2011 10:30

    19

    Thanks! I’ve been getting those errors in a couple of little websites. Now I know what the heck is going on and have written on it also

    0
  • Alexander Theis

    Thursday, January 6th, 2011 09:57

    17

    Hi this is a really nice guide. But i have following problem.
    If I click on Save or Reset i will get an error.
    “Warning: Cannot modify header information – headers already sent by… ”

    Does anybody know something about it? Error is in this line
    “header(“Location: themes.php?page=functions.php&saved=true”);”
    “header(“Location: themes.php?page=functions.php&reset=true”);

    -1
  • dev

    Monday, November 29th, 2010 10:35

    16

    great tutorial thanks :)

    0
  • Ravi

    Monday, August 30th, 2010 07:39

    15

    Great tutorial.
    Thank you for sharing :)

    @Scott Corgan,
    “header already sent” error is most probable because you have few empty lines in functions.php file

    remove all empty lines from functions.php file and error should be gone.

    +2
  • Scott Corgan

    Tuesday, July 6th, 2010 19:10

    14

    Having issues with “header already sent” any ideas?

    Thanks.

    0
    • Sean Thompson

      Saturday, February 12th, 2011 01:50

      18

      Functions.php is very touchy. In PHP you cant have any blank lines. So take out any blank lines and you should be good.

      +1
  • riesurya

    Thursday, June 3rd, 2010 17:31

    13

    clearly explained tutorial. I’ll try in my next WP theme.

    0
  • Naeem

    Tuesday, May 25th, 2010 15:33

    12

    Very nice article, a must bookmark!

    0
  • WordPress 101

    Monday, May 24th, 2010 19:18

    11

    Great tutorial! Options pages are becoming almost required for anyone who customizes themes, or creates WordPress sites for their clients. Tweeted and shared this with my WordPress 101 members. Thanks again!

    0
  • Hein

    Monday, May 24th, 2010 15:31

    10

    Nice and helpful guide, great job. definitely going to use this ;)

    0
  • Jordan Walker

    Monday, May 24th, 2010 15:15

    9

    Great way to add customization to the administration section of wordpress for customers to update themes and other options.

    0
  • Sumeet Chawla

    Monday, May 24th, 2010 10:43

    8

    Just the thing I wanted! Thank you very much for the share… We can create very complex option pages depending on the theme I guess…

    0
  • Jean-Baptiste Jung

    Monday, May 24th, 2010 10:14

    7

    Great tutorial! I used to write a similar post one or two years ago but yours is most complete and up to date. Keep ut the great job!

    0
  • Auré

    Sunday, May 23rd, 2010 12:38

    6

    Interresting article, thanks for sharing :)

    0
  • Konstantin

    Saturday, May 22nd, 2010 12:30

    5

    I’m sorry, but I don’t like it at all.
    Have you ever heard of WordPress’ Settings API?
    Maybe you want to get familiar with the WordPress Core before you write tutorials that … are no good.

    +1
  • Mike Smith

    Saturday, May 22nd, 2010 05:11

    4

    Nice tutorial. I’m definitely going to have to try using these codes and tweaking them to fit my needs. Thanks for posting this up.

    -3
  • Patrick Offczorz

    Saturday, May 22nd, 2010 09:04

    3

    Great Tutorial. That’s exactly what I was looking for. Thanks m8

    0
  • nay

    Saturday, May 22nd, 2010 07:38

    2

    HI fri., thanks your training and tutorials. I really got experience for your tutorials. May be you too get a lot of knowledge and share to all other peoples.

    0
  • Matt @ Theme Thesis

    Friday, May 21st, 2010 23:27

    1

    Sweeeet. It’s nice to see all these options page tutorials creeping up now. When I first learned how to do them the resources around were so scarce, it was brutal. This is very nicely written, good job!

    0

Comments are closed.

54.204.66.38 - unknown - unknown - US