我想你在找add_meta_box
http://codex.wordpress.org/Function_Reference/add_meta_box
// Metabox actions
add_action( \'add_meta_boxes\', \'metabox_create\' ); // create
add_action( \'save_post\', \'metabox_save\' ); // save
// Create metabox
function metabox_create() {
add_meta_box( \'metabox_name\', \'Metabox Title\', \'metabox_content\', \'my_custom_post_type\', \'normal\', \'high\' );
}
// metabox content
function metabox_content() {
global $post;
// custom field data
$custom = get_post_custom( $post->ID );
$field_name = $custom[\'field_name\'][0];
// contents
?>
<label for="field_name">Field name</label>
<input name="field_name" id="field_name" value="<?php echo esc_attr( $field_name ); ?>" />
<?php
}
// save metabox fields
function metabox_save() {
global $post;
// Ignore autosave
if ( defined( \'DOING_AUTOSAVE\' ) && true === DOING_AUTOSAVE ) { return; }
// Save post meta.
update_post_meta( $post->ID, \'field_name\', $_POST[\'field_name\'] );
}