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

    }
}

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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