如果您是头版的用户,可以签入回调函数。
主题的示例代码functions.php
:
add_action( \'after_setup_theme\', \'wpse_67480_theme_setup\' );
function wpse_67480_theme_setup()
{
$bg_options = array (
\'wp-head-callback\' => \'wpse_67480_background_frontend\',
\'default-color\' => \'f0f0f0\',
\'default-image\' => \'\',
);
add_theme_support( \'custom-background\', $bg_options );
add_theme_support(
\'custom-header\',
array (
\'width\' => 960,
\'height\' => 200,
\'flex-height\' => TRUE,
\'flex-width\' => TRUE,
\'header-text\' => FALSE,
\'wp-head-callback\' => \'wpse_67480_header_frontend\',
)
);
}
wpse_67480_background_frontend()
{
if ( is_front_page() )
{
_custom_background_cb();
}
}
wpse_67480_header_frontend()
{
if ( ! is_front_page() )
{
return;
}
// create your header code here
}