WordPress.org

Support

Support » Plugins and Hacks » [Resolved] wp_head wp_enqueue_script – problem loading the script into head section

[Resolved] wp_head wp_enqueue_script – problem loading the script into head section

  • Hello. I’m at my wits end with this – maybe someone can help. I would like to use jQuery on my blog, but I cannot seem to get to enqueue using wp_enqueue_script(). This code is in a custom activated plugin:

    add_action('wp_head', 'mfDevLoadScripts');
    function mfDevLoadScripts() {
    	wp_enqueue_script('jquery');
    }

    Nothing happens! But… If I try:

    ‘add_action(‘wp_head’, ‘mfDevLoadScripts’);
    function mfDevLoadScripts() {
    print ‘flying monkeys’;
    }`

    I get “flying monkeys” printed across the top of my screen. Please help if you can!
    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • OK…. Answered my own question here. This is how you do it do it:

    add_action('init', 'mfDevLoadScripts');
    function mfDevLoadScripts() {
    	wp_enqueue_script('jquery');
    }
    Mark Barnes

    @mark8barnes

    For others who may read the thread, and need (like me) to use the wp_head hook rather than init, you can also use
    add_action('wp_head', 'mfDevLoadScripts', 0);
    to ensure the function loads early enough.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] wp_head wp_enqueue_script – problem loading the script into head section’ is closed to new replies.
Skip to toolbar