默认情况下,会隐藏一些元框。这些框存储在一个数组中,您可以在中找到wp-admin/includes/template.php#get_hidden_meta_boxes()
. 有一个过滤器,因此有机会使用插件:
<?php # -*- coding: utf-8 -*-
/*
Plugin Name: Enable Custom Fields per Default
Version: 1.0
Required: 3.1
Author: Thomas Scholz
Author URI: http://toscho.de
License: GPL
*/
! defined( \'ABSPATH\' ) and exit;
add_filter( \'default_hidden_meta_boxes\', \'enable_custom_fields_per_default\', 20, 1 );
/**
* Removes custom fields from the default hidden elements.
*
* The original ( wp-admin/includes/template.php#get_hidden_meta_boxes() ):
* array(
* \'slugdiv\',
* \'trackbacksdiv\',
* \'postcustom\', <-- we need this
* \'postexcerpt\',
* \'commentstatusdiv\',
* \'commentsdiv\',
* \'authordiv\',
* \'revisionsdiv\'
* )
*
* It has no effect if the user has decided to hide the box.
* This option is saved in "metaboxhidden_{$screen->id}"
*
* @param array $hidden
* @return array $hidden
*/
function enable_custom_fields_per_default( $hidden )
{
foreach ( $hidden as $i => $metabox )
{
if ( \'postcustom\' == $metabox )
{
unset ( $hidden[$i] );
}
}
return $hidden;
}
如您所见,启用更多字段非常简单。