I'm trying to add some Jquery scripts to my Wordpress site, and unfortunately I cannot link you to the site as I'm working locally. It seems that the Jquery file is being loaded, as well as the fancyboxStyle I created, but all of the other js scripts aren't loading.


function my_init() {
    if (!is_admin()) {
        wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js');

    // load JS files from my theme

    wp_enqueue_script('easing', get_bloginfo('template_url') . '/js/jquery.easing-1.3.pack.js', array('jquery'), '1.0', true, $in_footer);  

    wp_enqueue_script('mouseWheel', get_bloginfo('template_url') . '/js/jquery.mousewheel-3.0.4.pack.js', array('jquery'), '1.0', true, $in_footer);

    wp_register_style( 'fancyboxStyle', get_bloginfo('template_url') . '/css/fancybox.css', true);

    wp_enqueue_style( 'fancyboxStyle' );

    wp_enqueue_script('fancybox', get_bloginfo('template_url') . '/js/jquery.fancybox-1.3.4.pack.js', array('jquery'), '1.0', true, $in_footer);

    wp_enqueue_script('fancyboxControls', get_bloginfo('template_url') . '/js/fancybox/fancyboxControls.js', array('jquery'), '1.0', true, $in_footer);

add_action('init', 'my_init');

The files are all in the correct location, but the scripts do not load within the footer (or header for that matter).

Any help would be greatly appreciated.



  • Hi Roman, Thanks for the code but that doesn't seem to be working either. This time I don't actually have Jquery loaded either, but the fancyboxStyle is loading fine
    – remi90
    Sep 14, 2011 at 11:17
  • For the next time. Please comment to my answer and use @Roman so I get a notification from WPSE. I've added a comment below.
    – Roman
    Sep 14, 2011 at 14:35

1 Answer 1


You have multiple errors here.

  1. You're including CSS and JS on the same and wrong hook
  2. For JS you could use wp_enqueue_scripts
  3. For CSS you could use wp_print_styles
  4. wp_register_script / wp_enqueue_script only accepts 4 parameters.
  5. You should only register your scripts and enqueue only the last one with its dependencies. Use the third parameter to define these.

Try out this code:


add_action('wp_print_styles', 'wpse28490_enqueueStyles');
function wpse28490_enqueueStyles() {
    wp_register_style('fancyboxStyle', get_template_directory_uri() . '/css/fancybox.css');

add_action('wp_enqueue_scripts', 'wpse28490_enqueueScripts');
function wpse28490_enqueueScripts() {
    if(!is_admin()) {
        // If our site is using SSL, we should load our external scripts also in HTTPS
        $protocol = (is_ssl()) ? 'https://' : 'http://';

        // jQuery
        wp_register_script('jquery', $protocol . 'ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', array(), '1.6.2', true);

        // Custom scripts
        wp_register_script('jquery-easing', get_template_directory_uri() . '/js/jquery.easing-1.3.pack.js', array('jquery'), '1.0', true);  
        wp_register_script('jquery-mouseWheel', get_template_directory_uri() . '/js/jquery.mousewheel-3.0.4.pack.js', array('jquery'), '1.0', true);
        wp_register_script('jquery-fancybox', get_template_directory_uri() . '/js/jquery.fancybox-1.3.4.pack.js', array('jquery'), '1.0', true);
        // fancyboxControls needs jquery, jquery-mouseWheel and jquery-fancybox, so we could pass these ids to the third parameter as an array.
        wp_register_script('fancyboxControls', get_template_directory_uri() . '/js/fancybox/fancyboxControls.js', array('jquery', 'jquery-easing', 'jquery-mouseWheel', 'jquery-fancybox'), '1.0', true);

        // Everything is registred, just enqueue our last script
  • @remi90 The above script is working on a default installation. Please check your sourcecode. It could be that another script needs jQuery before the wp_footer hook and therefore include jquery in the header. Try disabling your plugins and test again.
    – Roman
    Sep 14, 2011 at 14:37
  • It does indeed appear to work after disabling some plugins. Thank you Roman
    – remi90
    Sep 14, 2011 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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