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.

Below is my code for enqueue my scripts and css. I am trying to get the JavaScripts to load in the footer of my site, but when I view source I see them loading in the header. I suppose the "true" value isn't working properly or I have sequenced the code incorrectly?

// Enque CSS and JavaScript
if (!is_admin()) {

// CSS Reset
wp_register_style( 'reset', get_template_directory_uri() . '/css/reset.css');
wp_enqueue_style( 'reset' );

// 960 GS
wp_register_style( 'grid', get_template_directory_uri() . '/css/960.css');
wp_enqueue_style( 'grid' );

// Style
wp_register_style( 'style', get_template_directory_uri() . '/style.css');
wp_enqueue_style( 'style' );

// jQuery
wp_deregister_script('jquery');
wp_register_script('jquery',("http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"), true);
wp_enqueue_script('jquery');

// jQuery UI
wp_deregister_script('jquery-ui-core');
wp_register_script('jquery-ui-core',("https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"), true);
wp_enqueue_script('jquery-ui-core');

// Easy Slider
wp_register_script('easy-slider',get_bloginfo('template_directory') . "/js/easySlider1.7.js", true);
wp_enqueue_script('easy-slider');

// Scripts
wp_register_script('myscript',get_bloginfo('template_directory') . "/js/scripts.js", true);
wp_enqueue_script('myscript');

// Facebook API
wp_register_script('facebook-loader',("http://static.ak.fbcdn.net/connect.php/js/FB.Loader"), true);
wp_enqueue_script('facebook-loader');
wp_register_script('facebook-sharer',("http://static.ak.fbcdn.net/connect.php/js/FB.Share"), true);
wp_enqueue_script('facebook-sharer');

// Twitter API
wp_register_script('twitter',("//platform.twitter.com/widgets.js"), true);
wp_enqueue_script('twitter');

}
share|improve this question
    
What hook are you using for this? You should be using wp_enqueue_scripts for both CSS and JS and you can ditch the is_admin check if you are. –  Joseph Jul 30 '12 at 0:06

1 Answer 1

up vote 2 down vote accepted

You need top put it into an actual function and then call the function via an action, but to answer your question.

wp_register_script('easy-slider',get_bloginfo('template_directory') . "/js/easySlider1.7.js", true);

Your setting the third parameter to true but that param is for the $deps (dependency). The footer is the 5th parameter called $in_footer.

So it should be:

 wp_register_script('easy-slider',get_bloginfo('template_directory') . "/js/easySlider1.7.js", '', '', true);

Reference:

 wp_register_script( $handle, $src, $deps, $ver, $in_footer );
share|improve this answer

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.