1

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

    }
}
New contributor
Uzair is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0

Looks like you may need to use a custom hook unique to Elementor Pro: https://code.elementor.com/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' );
    }
} );
New contributor
mikerojas is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Uzair is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.