获取已保存的自定义CSS内容以进行渲染。
原型
wp_get_custom_css( string $stylesheet = '' )
参数
$stylesheet
(string)
(Optional)
主题对象样式表名称。默认为当前主题。
返回值
(string)
自定义CSS帖子内容。
源文件
路径:wp-includes/theme.php
<?php
...
function wp_get_custom_css( $stylesheet = '' ) {
$css = '';
if ( empty( $stylesheet ) ) {
$stylesheet = get_stylesheet();
}
$post = wp_get_custom_css_post( $stylesheet );
if ( $post ) {
$css = $post->post_content;
}
/**
* Filters the Custom CSS Output into the <head>.
*
* @since 4.7.0
*
* @param string $css CSS pulled in from the Custom CSS CPT.
* @param string $stylesheet The theme stylesheet name.
*/
$css = apply_filters( 'wp_get_custom_css', $css, $stylesheet );
return $css;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_get_custom_css/