【发布时间】:2017-11-18 17:49:00
【问题描述】:
我的样式表可以加载到我的 wordpress 主题中的所有页面上。我想在landing.php 中禁用它。 文件在这个地址:http://example.com/wp-content/uploads/fusion-styles/fusion-22528.css 到目前为止,我已经尝试过这些代码:
function themeslug_enqueue_style() {
if (is_page_template( 'landing.php' )) {
wp_enqueue_style( 'stylesheet', 'http://example.com/wp-
content/uploads/fusion-styles/fusion-22528.css', false );
}
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
还有这个:
function se_remove_styles() {
if ( is_page_template( 'landing.php' ) ) {
wp_dequeue_style( 'http://example.com/wp-content/uploads/fusion-
styles/fusion-22528.css?timestamp=1510985246&ver=4.9' );
}
}
add_action( 'wp_print_styles', 'se_remove_styles', 99999 );action(
'wp_print_styles', 'se_remove_all_styles', 999999 );
但没有奏效。我曾使用此代码:
function se_remove_all_styles() {
global $wp_styles;
if ( is_page_template( 'landing.php' ) ) {
$wp_styles->queue = array();
}
}
add_action( 'wp_print_styles', 'se_remove_all_styles', 99 );
但它会删除我所有的样式。
任何帮助将不胜感激。
【问题讨论】:
-
这种风格排在哪里?它的句柄名称是什么?在 wp_dequeue_style 中使用 css URL 是不正确的。您可以只使用句柄名称。
-
我是 wordpress 编码的新手 @Elvin85。我怎样才能得到句柄名称?我怎么知道这种风格在哪里排队?
-
好的,我现在添加答案