I want to enqueue stylesheet to plugin I’m developing, like this:

function utm_user_scripts() {
    $plugin_url = plugin_dir_url( __FILE__ );
    wp_enqueue_style( 'style',  $plugin_url . "/css/style.css");
}
add_action( 'wp_enqueue_scripts', 'utm_user_scripts' );

I am adding this code in the main file, [plugin_name].php.

Nothing is loaded, which part am I doing wrong?

2 Answers
2

Add this code in your main file: [plugin-name].php:

    function utm_user_scripts() {
            $plugin_url = plugin_dir_url( __FILE__ );

        wp_enqueue_style( 'style',  $plugin_url . "/css/style.css");
    }

    add_action( 'admin_print_styles', 'utm_user_scripts' );

So basically, you need to use ‘admin_print_styles’. At least it did the trick for me.

Leave a Reply

Your email address will not be published. Required fields are marked *