wordpress – front end css applied in admin panel

I am working on a plugin which loads its own css for front end and it is working fine. But the same css is also being applied for admin dashboard. i want to prevent the plugin css loading in admin dashboard.
I have registered the css styles and enqeued prpperly to init but not able to understand what is causing the css to be loaded inside admin dashboard.
Below is the code I used to register and enqeue the stylesheet.

function skillapp_css(){
 wp_register_style('sh_css', plugins_url('assets/css/styles.css', __FILE__), false, 1.1);
 wp_enqueue_style('sh_css');}add_action('init', 'skillapp_css');

Related posts

1 comment

  1. You’re hooking too early. For styles and scripts you should be hooking to wp_enqueue_scripts for front end resources or admin_enqueue_scripts for admin resources.

    function skillapp_css(){
        wp_register_style('sh_css', plugins_url('assets/css/styles.css', __FILE__), false, 1.1);
        wp_enqueue_style('sh_css');
    }
    add_action( 'wp_enqueue_scripts', 'skillapp_css' );
    

Comments are closed.