我想从特定模板中删除特定js文件。我已经看到了一些解决方案,并尝试了它们,但没有结果。接下来,我正在编写我尝试过的代码。
add_action(\'wp_enqueue_scripts\',\'theme_slug_dequeue_footer_jquery\');
function theme_slug_dequeue_footer_jquery() {
if ( is_page_template(\'property_list_half.php\') ) {
wp_dequeue_script(\'directory-js\');
wp_deregister_script(\'directory-js\');
}
}

最合适的回答,由SO网友:vjstereo 整理而成
试试这个。-js是由WordPress添加的,所以在调用它时不需要它。
function theme_slug_dequeue_footer_jquery() {
if ( is_page_template(\'property_list_half.php\') ) {
wp_dequeue_style( \'directory\' );
}
}
add_action(\'wp_enqueue_scripts\',\'theme_slug_dequeue_footer_jquery\');