Support » Developing with WordPress » JS file queries

  • Steph Lopez


    Hi there,

    I am trying to add a JS file to the end of the page just before the closing body tag. I have read that I can set true in my enqueue line to set it in the footer, but when I set to true, is still adds it way up the page and not at the end.

    This is the line I am using:

    wp_enqueue_script( 'myscript', get_bloginfo('template_directory') . '/js/scripts.js', array( 'jquery' ), '', true );

    Can anyone tell me what I have done wrong?


    • This topic was modified 1 year ago by bcworkz. Reason: code fixed

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • threadi


    Your script is faulty, but I don’t know if it’s because of the missing code formatting here in the forum or if it’s already in your code. The 4th parameter is only a double inverted comma. This should generate a PHP error.

    Have a look at the manual:

    Correct would be:

    wp_enqueue_script( "myscript", get_bloginfo("template_directory") . "/js/scripts.js", array( "jquery" ), "", true );

    Also make sure this is inside the hook “wp_enqueue_scripts”. Examples can be seen in the manual above.

    Moderator bcworkz


    I’ve placed your code within the code formatting marks and the punctuation appears to be correct. Either single or double quotes are correct in this situation. To avoid formatting confusion in the future, always demarcate code with backticks or use the “code” button.

    Your code on its own ends up with a link reference in the footer when I tested it. But if other scripts specify “myscript” as a dependency which are in the head section, WP will also place your script link in head despite the footer designation.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘JS file queries’ is closed to new replies.