【问题标题】:How to not load style.css in a specific template如何不在特定模板中加载 style.css
【发布时间】:2016-10-25 04:13:51
【问题描述】:

在 wordpress 中,我创建了一个子主题,并根据子主题中 style.css 中的设计对某些模板进行了更改。

我还在子主题中创建了一个新模板,但我希望子主题中的 style.css 不与前端唯一的模板一起添加。我的模板文件名为template-custom.php

怎么做?

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    您可以使用wp_dequeue_style 函数来删除特定模板上的css

    试试下面的代码吧:

    /**
     * Remove specific style sheets.
     */
    function some_remove_styles() {
        if ( is_page_template( 'yourtemplate.php' ) ) {
            wp_dequeue_style( 'some-style' );
            wp_dequeue_style( 'some-other-style' );
        }
    }
    
    add_action( 'wp_print_styles', 'some_remove_styles', 99 );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-02
      • 2015-09-09
      • 2017-07-01
      • 2014-12-30
      • 1970-01-01
      相关资源
      最近更新 更多