To understand the Settings API I'm creating a custom settings page for a custom plugin. I have some trouble to save the settings, I have a single checkbox to test if the code works well, but if I check it and then click save button it will not be saved and didn't remain checked. What's wrong with the code? Is possible to use the -
caratchers for the ID of a settings field or section?
register_setting(
'general', // Settings section ID
'show-countdown' // Settings field ID - maybe the problem?
);
The code for the checkbox is the following.
<input type="checkbox" class="" id="show-countdown" name="show-countdown" value="1" <?php checked(1, get_option('show-countdown'), false); ?> />
<label for="show-countdown"><?php echo $args[0]; ?></label>
NB: the register_settings_section()
and register_settings_field()
are working fine, this is why I omit the code.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744837871a4596373.html
评论列表(0条)