【发布时间】:2016-10-25 04:13:51
【问题描述】:
在 wordpress 中,我创建了一个子主题,并根据子主题中 style.css 中的设计对某些模板进行了更改。
我还在子主题中创建了一个新模板,但我希望子主题中的 style.css 不与前端唯一的模板一起添加。我的模板文件名为template-custom.php。
怎么做?
【问题讨论】:
标签: wordpress
在 wordpress 中,我创建了一个子主题,并根据子主题中 style.css 中的设计对某些模板进行了更改。
我还在子主题中创建了一个新模板,但我希望子主题中的 style.css 不与前端唯一的模板一起添加。我的模板文件名为template-custom.php。
怎么做?
【问题讨论】:
标签: wordpress
您可以使用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 );
【讨论】: