add_action('add_meta_boxes', 'lft_hotel_section_box');
function lft_hotel_section_box(){
$screens = array( 'parsing' );
add_meta_box( 'lft_section_hotel', 'Отель ', 'lft_hotel_section_callback', $screens );
}
function lft_hotel_section_callback( $post, $meta ){
$screens = $meta['args'];
wp_nonce_field( plugin_basename(__FILE__), 'lft_noncename' );
$args = array(
'numberposts' => 0,
'post_type' => 'hotel'
);
$catPosts = get_posts($args);
foreach ($catPosts as $singlePost) {
echo '<input type="checkbox" id="lft_checkbox" name="lft_checkbox">'.$singlePost->post_title. ' ' .$singlePost->ID. get_post_meta( $post->ID, 'checkbox_hotel_key', true ) . '</input>';
};
add_action( 'save_post', 'lft_save_checkbox' );
function lft_save_checkbox( $post_id )
{
if (!isset($_POST['lft_checkbox']))
return;
$checkbox_hotel = sanitize_text_field($_POST['lft_checkbox']);
update_post_meta($post_id, 'checkbox_hotel_key', $checkbox_hotel);
}};
echo '<form method="POST">';
foreach ($catPosts as $singlePost) {
echo '<input type="checkbox" id="lft_checkbox" name="lft_checkbox">'.$singlePost->post_title. ' ' .$singlePost->ID. get_post_meta( $post->ID, 'checkbox_hotel_key', true ) . '</input>';
};
echo '</form>';