Hi, I am trying to make a simple modification to a theme that I downloaded and I am having some trouble. I added a checkbox to the theme options form but I can't get the checkbox to reflect the value saved to the options after submitting. It always remains checked.
This statement reflects the way I have tried to accomplish this:
<p><input type="checkbox" name="usethemegravatar" value="true" checked=<?php echo get_option('usethemegravatar'); ?> />
Also at the end I have a hidden input in the form:
<input type="hidden" name="page_options" value="feedid,greeting,welcomemessage,usethemegravatar" />
I have also tried setting up an array with an initial value in it and then changing the value when the form is submitted but I haven't been able to get that working either. I am new to Wordpress and PHP so I am still learning how it all works. Thanks for any help!
This is the full editoptions() from function.php
function editoptions() {
<div class='wrap'>
<h2>Theme Options</h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<p><strong>Greeting Heading:</strong></p>
<p><input type="text" name="greeting" value="<?php echo get_option('greeting'); ?>" /></p>
<p><strong>Welcome Message:</strong>If you don't specify a message, a default will be used.</p>
<p><textarea name="welcomemessage" cols="100%" rows="10"><?php echo get_option('welcomemessage'); ?></textarea></p>
<p><strong>Post your "Subscription Form Code" from the Feedburner website here.</strong></p>
<p><textarea name="feedid" cols="100%" rows="10"><?php echo get_option('feedid'); ?></textarea></p>
<p></p>
<p><input type="checkbox" name="usethemegravatar" value="true" checked=<?php echo get_option('usethemegravatar'); ?> />
Use the theme default Gravatar. If not the Wordpress default will be used.</p>
<p><input type="submit" name="Submit" value="Update Options" /></p>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="feedid,greeting,welcomemessage,usethemegravatar" />
</form>
</div>
<?php
}