按照建议更改表单:
function startdate() {
global $post;
$custom = get_post_custom($post->ID);
echo "<label>Startdates</label><br/>";
for ($i=0; $i<count($custom["startdate"]);$i++) {
echo "<input type=\\"text\\" name=\\"startdate[".$i."]\\" value=\\"".$custom["startdate"][$i]."\\" />";
}
}
您必须删除并恢复您的个人Posteta条目:
add_action(\'save_post\', \'save_details\');
function save_details($post_id) {
if ($parent_id = wp_is_post_revision($post_id)) $post_id = $parent_id;
if (!empty($_POST[\'startdate\']) && is_array($_POST[\'startdate\'])) {
delete_post_meta($post_id, \'startdate\');
foreach ($_POST[\'startdate\'] as $startdate) {
add_post_meta($post_id, \'startdate\', $startdate);
}
}
}
然后,当然,您需要向metabox表单添加某种添加/删除机制,可能是通过JS。