记录中有复选框,是否有必要挂钩其Ajax值(已注明)以获取get_post_meta并从该字段获取数据,并通过逗号删除其他字段(id = parsing_night_key)?>
function lft_checkbox_meta() {
add_meta_box(
'lft-checkbox',
__( 'Отели', 'undefined' ),
'myplugin_inner_custom_box',
'parsing',
'normal',
'default'
);
}
add_action( 'add_meta_boxes', 'lft_checkbox_meta' );
function myplugin_inner_custom_box( $post ) {
$checkfield = maybe_unserialize( get_post_meta($post->ID, "checkfield", true) );
wp_nonce_field( 'save_quote_meta', 'custom_nonce' );
$args = array(
'numberposts' => 0,
'post_type' => 'hotel'
);
$hotels = get_posts($args);
foreach ( $hotels as $page ) { ?>
<input id="need_check" type="checkbox" name="checkfield[]" value="<?php echo $page->ID; ?>" <?php if ( in_array($page->ID, (array) $checkfield) ) { ?> checked <?php } ?>/> <label for="page_<?php echo $page->ID; ?>"><?php echo $page->post_title; ?></label> <br>
<?php
}
}