首页 > 解决方案 > 需要帮助将 WordPress 短代码添加到我的 CSS 页面

问题描述

#investment-focus-hero .jumbotron {
    background: /* top, transparent red, faked with gradient */ linear-gradient( rgba(255 , 255, 255, 0.05), rgba(0, 0, 0, 0.85)), /* bottom, image */ url('<?php echo do_shortcode('[acf field="jumbotron_full_image" post_id="237"]'); ?>');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    padding-top: 37.42%;
}

标签: phpcsswordpressshortcode

解决方案


将文件的扩展名更改为 php,然后更新链接标签的文件路径,您可以在其中加载标题中的 CSS 文件。

因此,您的链接标签将从以下位置开始:

<link href="css/styles.css" rel="stylesheet" type="text/css" />

对此:

<link href="css/styles.php" rel="stylesheet" type="text/css" />

这样 CSS 就由服务器运行了!


推荐阅读