wp_enqueue_style in Plugin

When I enqueue a css style in a plugin like so:

function add_my_stylesheet() 
{
    wp_enqueue_style( 'myCSS', plugins_url( '/css/myCSS.css', __FILE__ ) );
}

add_action('init', 'add_my_stylesheet');

Is ‘init’ the correct action to use? It works fine. Is there any reason not to do it this way? Is this the standard way? I want to follow the best practices.

Read More

Thank you.

-Laxmidi

Related posts

Leave a Reply

1 comment

  1. You can use admin_print_styles for your hook, this is the preferred method for adding a style to your plugin or admin page.

    add_action('admin_print_styles', 'add_my_stylesheet');