请阅读Updating Custom Backgrounds and Custom Headers for WordPress 3.4.
自定义标题
旧方法:
// Define default header image constant
define( \'HEADER_IMAGE\', get_template_directory_uri() . \'/images/headers/default.jpg\' );
// Define header image width constant
define( \'HEADER_IMAGE_WIDTH\', 1000 );
// Define header image height constant
define( \'HEADER_IMAGE_HEIGHT\', 198 );
// Define header text constant
define( \'NO_HEADER_TEXT\', false );
// Define header text color constant
define( \'HEADER_TEXTCOLOR\', \'000\' );
// Turn on random header image rotation by default.
// Requires HEADER_IMAGE to be null
add_theme_support( \'custom-header\', array( \'random-default\' => true ) );
// Add Theme support
add_custom_image_header( $wphead_cb, $adminhead_cb, $adminpreview_cb );
新方法:
add_theme_support( \'custom-header\', array(
// Header image default
\'default-image\' => get_template_directory_uri() . \'/images/headers/default.jpg\',
// Header text display default
\'header-text\' => false,
// Header text color default
\'default-text-color\' => \'000\',
// Header image width (in pixels)
\'width\' => 1000,
// Header image height (in pixels)
\'height\' => 198,
// Header image random rotation default
\'random-default\' => false,
// Template header style callback
\'wp-head-callback\' => $wphead_cb,
// Admin header style callback
\'admin-head-callback\' => $adminhead_cb,
// Admin preview style callback
\'admin-preview-callback\' => $adminpreview_cb
) );
再说一遍:那很容易,不是吗?
为了澄清,以下是旧的常量/新的数组键等价物:
HEADER_IMAGE => \'default-image\'
HEADER_IMAGE_WIDTH => \'width\'
HEADER_IMAGE_HEIGHT => \'height\'
NO_HEADER_TEXT => \'header-text\'
HEADER_TEXTCOLOR => \'default-text-color\'
与之前一样,支持所有相同的回调。
以下是完整的默认值数组供参考:
$defaults = array(
\'default-image\' => \'\',
\'random-default\' => false,
\'width\' => 0,
\'height\' => 0,
\'flex-height\' => false,
\'flex-width\' => false,
\'default-text-color\' => \'\',
\'header-text\' => true,
\'uploads\' => true,
\'wp-head-callback\' => \'\',
\'admin-head-callback\' => \'\',
\'admin-preview-callback\' => \'\',
);