Exclude stylesheet from admin

I have been using the following function to enqueue some CSS to my theme. However, they are used in the admin area as well:

wp_enqueue_style(...)

I don’t want them to be used in the admin area. Sadly I cannot find anything about that neither here nor on Google in combination with this function. The codex doesn’t explain it as well and the function does not support an option to apply to a specific style the exclusion of the admin area.

Read More

I hope somebody could tell me how to exclude a specific css from the admin area.

Thanks in advance.

Related posts

Leave a Reply

3 comments

  1. There are a couple of options. One is to wrap the enqueue in a check to see if it is the admin.

    if(!is_admin()) 
        wp_enqueue_style(....);
    

    The other is wait to enqueue the style until template_redirect.

    function my_enqueue_styles() {    
        wp_enqueue_style(....);
    }
    add_action( 'template_redirect', 'my_enqueue_styles' );
    
  2. You can make your enquques conditional, for example: if( !is_admin() ) { wp_enquque_style( 'my_style' ) }. Any of the conditional tags will work in this way.