我试图使用设置API在自定义选项页上使用复选框。每件事在后端都可以正常工作,我可以通过注册设置来更新复选框状态。但是当我想在页面上看到结果时,我得到了相同的结果" The checkbox has not been checked." 即使如此,复选框已在选项上进行检查和更新。php和我的自定义选项页面!
以下是更新和保存复选框状态的方法:
public function contactprice_setting(){
$options = get_option(\'price_display_options\');
$html = \'<input type="checkbox" id="checkbox_contactprice" name="price_display_options[checkbox_contactprice]" value="1"\' . checked( 1, $options[\'checkbox_contactprice\'], false ) . \'/>\';
$html .= \'<label for="checkbox_contactprice">Uncheck The Text Box</label>\';
echo $html;
}
正如我所说的,这部分工作得很好,但当我尝试在索引中输出结果时。php组件:<?php if( $input_examples[\'checkbox_contactprice\'] == \'1\' ) { ?>
<p>The checkbox checkbox has been checked.</p>
<?php } else { ?>
<p>The checkbox has not been checked.</p>
<?php } // end if ?>
正如我提到的,我得到了"The checkbox has not been checked." 在已检查或已检查的情况下。你能告诉我为什么要买这个吗?