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' );
}
} );