Imho,最快的方法是使用Meta Box Wrapper Class, 这是一个插件。下载并激活它。
Next in your functions.php add the following:
$prefix = \'cheas_cool_metabox_\';
global $meta_boxes;
$meta_boxes = array();
$meta_boxes[] = array(
\'id\' => \'movie_reviews\',
\'title\' => \'Movie Review\',
//Change the next line if you want to display on another post type
\'pages\' => array( \'post\' ),
\'context\' => \'side\',
\'priority\' => \'high\',
// List of meta fields
\'fields\' => array(
array(
// Field name - Will be used as label
\'name\' => \'Movie Title\',
// Field ID, i.e. the meta key
\'id\' => $prefix . \'movie_title\',
\'type\' => \'text\',
),
array(
\'name\' => \'Review\',
\'id\' => $prefix . \'movie_review\',
\'type\' => \'textarea\',
),
array(
\'name\' => \'Link\',
\'id\' => $prefix . \'movie_link\',
\'desc\' => \'Youtube Link\',
\'type\' => \'text\',
),
),
);
function cheas_cool_metabox_register_meta_boxes()
{
global $meta_boxes;
if ( class_exists( \'RW_Meta_Box\' ) )
{
foreach ( $meta_boxes as $meta_box )
{
new RW_Meta_Box( $meta_box );
}
}
}
add_action( \'admin_init\', \'cheas_cool_metabox_register_meta_boxes\' );
Now all you need to do is to call it on your post page:
Movie: <?php echo rwmb_meta( \'cheas_cool_metabox_movie_title\' ); ?>
Review: <?php echo rwmb_meta( \'cheas_cool_metabox_movie_review\' ); ?>
Watch Trailer for <a href="<?php echo rwmb_meta( \'cheas_cool_metabox_movie_link\' ); ?>" target="_blank"><?php echo rwmb_meta( \'cheas_cool_metabox_movie_title\' ); ?></a>
这应该可以满足您的需要,但请查看主插件目录中的demo文件夹,以查看更多不同元框类型的示例