【问题标题】:Output individual page header style and footer script using ACF使用 ACF 输出单个页眉样式和页脚脚本
【发布时间】:2019-06-02 20:13:55
【问题描述】:

我正在尝试使用 ACF 为 Wordpress 中的各个页面输出自定义 CSS 和页脚脚本。我在 ACF 上使用 textarea 字段。

我已将此代码添加到 header.php 文件中。

if( get_field('custom_page_css')) {
$customCss = the_field('custom_page_css');
   echo '<style type="text/css" media="screen">' . $customCss . '</style>';
}

问题在于样式标签之外的 css 输出。

【问题讨论】:

  • .acf-style { display:none; }

标签: php html css advanced-custom-fields


【解决方案1】:

使用get_field()函数:

$customCss = get_field('custom_page_css');

而不是

$customCss = the_field('custom_page_css');

【讨论】:

    猜你喜欢
    • 2020-08-23
    • 2014-02-17
    • 1970-01-01
    • 1970-01-01
    • 2012-10-16
    • 1970-01-01
    • 2013-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多