【问题标题】:Bootstrap files get priority over my child theme style.css file引导文件优先于我的子主题 style.css 文件
【发布时间】:2021-08-07 06:37:53
【问题描述】:

我正在创建自定义 WordPress 主题。我有一个子主题和父主题。 一个问题是我的子主题 function.php 文件没有添加引导文件,所以我在父主题中调用它,但现在我遇到的问题是引导 CSS 优先于我的子 style.css。

我已在我的子主题 function.php 文件中尝试过此代码,但它不起作用。 它没有在视图源中显示任何 custom.css。我的两个文件都在正确的路径中

add_action('wp_enqueue_scripts', 'theme_enqueue_styles', 100);
function theme_enqueue_styles()
{   $parent_style = 'flambird-style';
    $child_style = array('flambird-style');
    wp_enqueue_style($parent_style, get_template_directory_uri() . '/bootstrap/custom.css', array());
    wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/css/custom.css', $child_style);
}

在这两种情况下都没有添加自定义。我认为我的子主题 function.php 文件不起作用。 请帮助我。我想使用子主题 css 文件。

enter image description here

【问题讨论】:

    标签: php wordpress custom-wordpress-pages


    【解决方案1】:

    当发生冲突时,将 !important 添加到您的 css 格式中,或者托管您自己的带有兼容更改的 Bootstrap 副本。

    【讨论】:

    • 不,我不想使用 !important,因为它会影响响应,并且我在我的服务器上托管引导程序而不使用 CDN 路径
    猜你喜欢
    • 2015-10-27
    • 2021-01-16
    • 2012-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多