我相信这回答了你的两个问题(这和this), 看看My Meta box class 它允许在自定义元数据库中添加任何类型的字段。
一旦你上了这门课,你需要做的就是这样:
//include the main class file
require_once("meta-box-class/my-meta-box-class.php");
// configure your meta box
$config = array(
\'id\' => \'event_review_box\', // meta box id, unique per meta box
\'title\' => \'Event Review\', // meta box title
\'pages\' => array(\'event\'), // post types, assuming that your post type name is event
\'context\' => \'normal\', // where the meta box appear: normal (default), advanced, side; optional
\'priority\' => \'high\', // order of meta box: high (default), low; optional
\'fields\' => array(), // list of meta fields (can be added by field arrays) or using the class\'s functions
\'local_images\' => false, // Use local or hosted images (meta box images for add/remove)
\'use_with_theme\' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);
// Initiate your meta box
$my_meta2 = new AT_Meta_Box($config);
//Add fields to your meta box
$my_meta2->addWysiwyg(\'wysiwyg_field_id\',array(\'name\'=> \'Event Recap\'));
//Finish Meta Box Deceleration
$my_meta2->Finish();
然后为“事件日期”字段添加新的元框
// configure your meta box
$config = array(
\'id\' => \'event_date_box\', // meta box id, unique per meta box
\'title\' => \'Event date\', // meta box title
\'pages\' => array(\'event\'), // post types, assuming that your post type name is event
\'context\' => \'normal\', // where the meta box appear: normal (default), advanced, side; optional
\'priority\' => \'high\', // order of meta box: high (default), low; optional
\'fields\' => array(), // list of meta fields (can be added by field arrays) or using the class\'s functions
\'local_images\' => false, // Use local or hosted images (meta box images for add/remove)
\'use_with_theme\' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);
// Initiate your meta box
$my_meta = new AT_Meta_Box($config);
//Add fields to your meta box
$my_meta->addDate(\'date_field_id\',array(\'name\'=> \'Event Date \'));
//Finish Meta Box Deceleration
$my_meta->Finish();
你会得到这样的结果: