目錄
add_action( 'add_meta_boxes', 'custom_post_option_meta_box' );
function custom_post_option_meta_box() {
add_meta_box(
'custom_post_option_meta_group',
'Custom Post Options',
'custom_post_option_meta_box_callback',
'post'
);
}
function custom_post_option_meta_box_callback($post){
$post_id = $post->ID; ?>
add_action('save_post', 'save_post_private_note');
function save_post_private_note( $post_id ) {
if ( isset($_POST['private_note']) ) {
update_post_meta($post_id, 'private_note', esc_textarea($_POST['private_note']));
}
}