您可以通过多种方式做到这一点,例如:
add_filter( \'admin_post_thumbnail_html\', \'add_something_to_feature_thumb_box\');
function add_something_to_feature_thumb_box( $myhtml ) {
return $myhtml .= \'<p>Put your HTML here - if you want a form, put the form.</p>\';
}
或(更好的IMHO):
function replace_post_thumbnail_box() {
global $post; // get post
echo \'<p> if you want custom field above place code here .</p>\';
$thumbnail_id = get_post_meta( $post->ID, \'_thumbnail_id\', true ); // thumbnail ID from post array
echo _wp_post_thumbnail_html( $thumbnail_id );
echo \'<p>if you want custom field below place code here .</p>\';
}
function render_new_post_thumbnail_meta_box() {
global $post_type;
// get rid of the old box..
remove_meta_box( \'postimagediv\',\'post\',\'side\' );
// ..and render the new one
add_meta_box(\'postimagediv\', __(\'Featured Image\'), \'replace_post_thumbnail_box\', $post_type, \'side\', \'low\');
}
add_action(\'do_meta_boxes\', \'render_new_post_thumbnail_meta_box\');