i want to remove a specific js file from specific template. i have seen sone solutions and try them but got no result. following i am writing the code which i tried.
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');
}
}
i want to remove a specific js file from specific template. i have seen sone solutions and try them but got no result. following i am writing the code which i tried.
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');
}
}
Share
Improve this question
asked Feb 18, 2021 at 20:49
Talha ArifTalha Arif
31 bronze badge
2
|
1 Answer
Reset to default 0Try this out. The -js is added by WordPress, so you don't need it when you are calling it.
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');
add_action('wp_enqueue_scripts','theme_slug_dequeue_footer_jquery', 100 );
– Q Studio Commented Feb 18, 2021 at 21:17directory
. I believe the-js
part is added by WordPress. – Jacob Peattie Commented Feb 19, 2021 at 2:17