我有几个字段,大部分是文本输入,用于将其他信息保存到帖子中,所有文本框都保存了,但我无法获取复选框来保存值!
想知道你们这些天才中是否有人能帮助我。提前谢谢。
下面是复选框,我在复选框输入中回显了ck\\U销售
$ck_sale = get_post_meta($post->ID, \'ck_sale_item\', true); ?>
<?php //Save the information in the metabox
add_action( \'save_post\', \'mb_product_details_save\');
function mb_product_details_save( $post_id ) {
// Bail if we\'re doing an auto save
if( defined( \'DOING_AUTOSAVE\' ) && DOING_AUTOSAVE ) {
return;
}
// if our nonce isn\'t there, or we can\'t verify it, bail
if( !isset( $_POST[\'product_details_nonce\'] ) || !wp_verify_nonce( $_POST[\'product_details_nonce\'], \'mb_product_details_nonce\' ) ) {
return;
}
// if our current user can\'t edit this post, bail
if( !current_user_can( \'edit_post\' ) ) {
return;
}
//Set the data in the fields before saving
if( isset( $_POST[\'tb_RRP_price\'] ) ) {
update_post_meta( $post_id, \'tb_RRP_price\', wp_kses($_POST[\'tb_RRP_price\']));
}
if( isset( $_POST[\'tb_trade_price\'] ) ) {
update_post_meta( $post_id, \'tb_trade_price\', wp_kses($_POST[\'tb_trade_price\']));
}
if( isset( $_POST[\'tb_colours\'] ) ) {
update_post_meta( $post_id, \'tb_colours\', wp_kses($_POST[\'tb_colours\']));
}
if( isset( $_POST[\'tb_quantity\'] ) ) {
update_post_meta( $post_id, \'tb_quantity\', wp_kses($_POST[\'tb_quantity\']));
}
if($_POST["ck_sale_item"] == "on") {
$featured = "on";
}
else {
$featured = "off";
}
update_post_meta($post->ID, \'ck_sale_item\', $featured);
} ?>