• Resolved Anonymous User 16640517

    (@anonymized-16640517)


    Hi I am trying to enqueue css/js into the frontend of my plugin – i.e. whichever page/post has the plugin shortcode. I am using the following function. Weirdly, the css loads fine in the admin area, but nothing happens in the frontend. Any help would be highly appreciated.

    function load_my_style($hook) {	
    	wp_enqueue_style( 'my-style', plugins_url('style.css', __FILE__) );
    }
    add_action( 'admin_enqueue_scripts', 'load_my_style' );
    add_action( 'wp_enqueue_scripts', 'load_my_style' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hi there!

    Does it work if you use a different theme?

    Thread Starter Anonymous User 16640517

    (@anonymized-16640517)

    Hi yes just realised the plug-in loads in a different theme (not by me). So I am guessing my theme is missing a hook? Thanks a lot!

    Moderator bcworkz

    (@bcworkz)

    That’s right. Most themes call wp_head(). You don’t need to use this if you you are accomplishing head section elements by other means, but the important part of this function you will want to replicate is to do the “wp_head” action. All sorts of plugins rely upon this action to fire, so it’s essentially a required element of any theme. It’s normally done just before the closing </head> element.
    do_action('wp_head');

    Thread Starter Anonymous User 16640517

    (@anonymized-16640517)

    Thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_enqueue_scripts not working’ is closed to new replies.