admin管理员组文章数量:1389783
I am trying to remove style for non loggedin user & front page only.
i am trying this but didn't work. any idea where i am making mistake?
add_action( 'wp_print_styles', 'my_deregister_style', PHP_INT_MAX );
function my_deregister_style() {
if ( is_front_page() && !is_user_logged_in() ) {
wp_dequeue_style( 'elementor-pro' );
wp_deregister_style( 'elementor-pro' );
}
}
I am trying to remove style for non loggedin user & front page only.
i am trying this but didn't work. any idea where i am making mistake?
add_action( 'wp_print_styles', 'my_deregister_style', PHP_INT_MAX );
function my_deregister_style() {
if ( is_front_page() && !is_user_logged_in() ) {
wp_dequeue_style( 'elementor-pro' );
wp_deregister_style( 'elementor-pro' );
}
}
Share
Improve this question
asked Mar 25, 2020 at 17:20
UzairUzair
111 bronze badge
1 Answer
Reset to default 0Looks like you may need to use a custom hook unique to Elementor Pro: https://code.elementor/php-hooks/#elementorfrontendbefore_enqueue_scripts
The below example is un-tested but modified for your use case.
// Note: I think all you need is to dequeue the style to remove from the page
add_action( 'elementor/frontend/after_enqueue_styles', function() {
if ( is_front_page() && !is_user_logged_in() ) {
wp_dequeue_style( 'elementor-pro' );
}
} );
本文标签: functionsHow to properly remove style for non logged in and front page only
版权声明:本文标题:functions - How to properly remove style for non logged in and front page only 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744636636a2616860.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论