• 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)
  • Thread Starter Michael Fields

    (@mfields)

    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 ‘wp_head wp_enqueue_script – problem loading the script into head section’ is closed to new replies.