对于自定义帖子类型,它非常有效。。。
add_action(\'admin_init\', \'set_user_metaboxes\');
function set_user_metaboxes($user_id=NULL) {
// These are the metakeys we will need to update
$meta_key[\'order\'] = \'meta-box-order_event\';
$meta_key[\'hidden\'] = \'metaboxhidden_event\';
$brand_meta_key[\'order\']=\'meta-box-order_brand\';
$venue_meta_key[\'order\']=\'meta-box-order_venue\';
// So this can be used without hooking into user_register
if ( ! $user_id)
$user_id = get_current_user_id();
// Set the default order if it has not been set yet
$meta_value = array(
\'side\' => \'submitdiv,formatdiv,categorydiv\',
\'normal\' => \'postimagediv,event_type,eventfeaturedbrand,event_details,description_sectionid\',
\'advanced\' => \'\',
);
$brand_meta_value = array(
\'side\' => \'submitdiv,categorydiv\',
\'normal\' => \'postimagediv,product_type\',
\'advanced\' => \'\',
);
$venue_meta_value = array(
\'side\' => \'submitdiv,categorydiv\',
\'normal\' => \'venue_post_details,postimagediv\',
\'advanced\' => \'\',
);
update_user_meta( $user_id, $meta_key[\'order\'], $meta_value );
update_user_meta( $user_id, $brand_meta_key[\'order\'], $brand_meta_value );
update_user_meta( $user_id, $venue_meta_key[\'order\'], $venue_meta_value );
// Set the default hiddens if it has not been set yet
if ( get_user_meta( $user_id, $meta_key[\'hidden\'], true) ) {
$meta_value = array(\'postcustom\',\'trackbacksdiv\',\'commentstatusdiv\',\'commentsdiv\',\'slugdiv\',\'authordiv\',\'revisionsdiv\');
update_user_meta( $user_id, $meta_key[\'hidden\'], $meta_value );
}
}