• saintehlers

    (@saintehlers)


    Please let me get a direct answer instead of “go find an example” or “you’re doing it wrong.” I know I’m doing it wrong, that’s why I’m asking.

    So, this is what I have in my functions.php file

    function mdg_setup_scripts() {
      $mdgtemplateloc = get_bloginfo( 'template_url' ).'/js/';
      wp_register_script( 'hoverIntent', get_bloginfo('template_url').'/js/hoverIntent.js', array( 'jquery' ));
      wp_enqueue_script( 'hoverIntent' );
      wp_register_script( 'mdMenuAnimation', $mdgtemplateloc.'mdMenuAnimation.js', array( 'hoverIntent' ));
      wp_enqueue_script( 'mdMenuAnimation' );
    }
    add_action( 'wp_enqueue_scripts', 'mdg_setup_scripts' );

    No <script> tag appears at all in the HTML generated.

    Am I missing something I was supposed to put in the header.php to call this? What did I do wrong?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Andrew Bartel

    (@andrew-bartel)

    I’ve always put my javascript in the <head> tag, so, in the header. But some people prefer it in the footer now.

    Bob

    (@prasunsen)

    You seem to be doing it right. I’m just having exactly the same problem on one blog (works fine on all other) – used “wp_enqueue_scripts” action but no script tag appears. I’ll write again if I find the source of the problem.

    Bob

    (@prasunsen)

    Andrew was right, when removing $in_footer argument it started working. Apparently some themes don’t properly call get_footer();

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wp_enqueue_scripts – what am I doing wrong?’ is closed to new replies.