php - 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

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

相关推荐

  • php - 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

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信