我从来都不确定“最佳方法”,但是,我在函数中使用了它。php在儿童主题中的应用
//deregister the header images of Twenty Eleven, and register a few new RAW header images//
add_action( \'after_setup_theme\', \'raw_theme_header_images\', 11 );
function raw_theme_header_images() {
unregister_default_headers( array( \'wheel\', \'shore\', \'trolley\', \'pine-cone\', \'chessboard\', \'lanterns\', \'willow\', \'hanoi\' ) );
$folder = get_stylesheet_directory_uri();
register_default_headers( array(
\'coleslaw\' => array(
\'url\' => $folder.\'/images/headers/coleslaw.jpg\',
\'thumbnail_url\' => $folder.\'/images/headers/coleslaw-thumb.jpg\',
/* translators: header image description */
\'description\' => __( \'Coleslaw\', \'twentyeleven\' )
),
\'tomato_and_sprouts\' => array(
\'url\' => $folder.\'/images/headers/tomato_and_sprouts.jpg\',
\'thumbnail_url\' => $folder.\'/images/headers/tomato_and_sprouts-thumb.jpg\',
/* translators: header image description */
\'description\' => __( \'Tomato and Sprouts\', \'twentyeleven\' )
)
)
);
}
新图像位于子主题的/images文件夹中。