register_setting not save checkbox
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; ?></label>
register_settings_field() are working fine, this is why I omit the code.