2

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?

3

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.

1

I did a quick Google Search on how to enqueue styles for Plugins and I've came across these two questions on WordPress StackExchange. You can find them below and hopefully they will help you solve your problem.

Best of Luck :)

wp_enqueue_style for Plugin with multiple stylesheets

Where is the right place to register/enqueue scripts & styles

  • I have seen these and did as instructed, but it's still not included. – ivanacorovic Feb 22 '16 at 11:40
  • Then we need more information on the matter - are you getting errors in the console? Try some debugging and then post what you get and I'd be happy to help even more :) – Stephen Feb 22 '16 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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