我正在尝试使用ACF为Wordpress中的单个页面输出自定义CSS和页脚脚本。我正在使用 ACF 上的文本区域字段。
我已将此代码添加到标头.php文件中。
if( get_field('custom_page_css')) {
$customCss = the_field('custom_page_css');
echo '<style type="text/css" media="screen">' . $customCss . '</style>';
}
问题是样式标记之外的 css 输出。
使用 get_field()
函数:
$customCss = get_field('custom_page_css');
而不是
$customCss = the_field('custom_page_css');