Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using this code to plant a script on a spesific page, it works but inserts the script into the bottom of the page not the top - I'm at a loss to explain why! Is there a way to do this that results in the script being inserted inside the head tags.

function single_page_load() {
    if ( !is_page_template( 'interactive-map.php' ) )
    return;
        wp_enqueue_script( 'map', get_template_directory_uri() . 'jquery-map/map.js', array('jquery'), '1.4.2', true );
    }
add_action( 'template_redirect', 'single_page_load' );
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

wp_enqueue_script accepts 5 parameters. The fifth one is $in_footer. If that parameter is set to true the script will load in the footer.

If it is set to false it will load in the head, unless a dependency (like jQuery in your code) is set to show up in the footer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.