我正在尝试开发一个动画库,这个库是在一个特定的页面上加载时附带的。这是脚本https://wpcalculators.com.ng/wp-content/plugins/elementor/assets/lib/animations/animations.min.css?ver=3.0.16的URL
我使用了这个代码:
//Remove animation
function remove_animation() {
if(is_page([19] )):
wp_dequeue_style( 'elementor-animations' );
endif;
}
add_action( 'wp_enqueue_scripts', 'remove_animation', 100 );但这是行不通的。
我使用了类似的代码来阻止Gutenberg块库的加载,它起了作用。
//Remove Gutenberg Block Library CSS from loading on the frontend
function smartwp_remove_wp_block_library_css() {
if(is_page([19] )):
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
endif;
}
add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css' );我从源代码中确认了CSS的ID,其内容如下:
Id似乎是“元素-动画”
否则,我如何才能编写代码使其工作呢?
注意:我知道当我用分页的洞察力测试URL时,它是不起作用的。
发布于 2021-01-16 02:53:24
可能,在去队列之前,取消注册样式可以解决这个问题。
function remove_animation() {
if ( is_page( [ 19 ] ) ):
wp_deregister_style( 'elementor-animations' );
wp_dequeue_style( 'elementor-animations' );
endif;
}
add_action( 'wp_enqueue_scripts', 'remove_animation', 100 );https://stackoverflow.com/questions/65740431
复制相似问题