admin管理员组

文章数量:1323732

I'm trying to dequeue some scripts on woocommerce product, but for some reason I can’t find a way to check for a single product.

is_singular('product') doesn't work for some reason. The dequeue itself works without the checks, e.g.:

add_action( 'wp_enqueue_scripts', 'my_custom_scripts', 100 );
function my_custom_scripts()
{
    wp_deregister_script( 'wp-mediaelement' );
    wp_deregister_style( 'wp-mediaelement' );
}

I'm trying to dequeue some scripts on woocommerce product, but for some reason I can’t find a way to check for a single product.

is_singular('product') doesn't work for some reason. The dequeue itself works without the checks, e.g.:

add_action( 'wp_enqueue_scripts', 'my_custom_scripts', 100 );
function my_custom_scripts()
{
    wp_deregister_script( 'wp-mediaelement' );
    wp_deregister_style( 'wp-mediaelement' );
}
Share Improve this question edited Sep 13, 2020 at 23:31 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Sep 13, 2020 at 16:33 RunnickRunnick 1,0593 gold badges14 silver badges26 bronze badges 1
  • I believe it's too early to use the conditional functions in that hook – Tom J Nowell Commented Sep 14, 2020 at 8:25
Add a comment  | 

1 Answer 1

Reset to default 1

https://docs.woocommerce/document/conditional-tags/

you can try is_product() its on the woocommerce docs

本文标签: How to dequeue script on woocommerce product