Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


William Whitworth
William Whitworth
6,117 Points

Just want to confirm if this looks right.

Hey all, I just added this to my Wordpress function.php file and it seems to be working, I just wanted to double check if this was the right method of calling jquery and its plugins.

    if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
    function my_jquery_enqueue() {
       wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") .     "://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js", false, null);

       wp_register_script('modernizr', get_template_directory_uri() . '/js/vendor/modernizr-2.6.2-respond-     1.1.0.min.js', array('jquery'), '', false );

       wp_register_script('columnizer', get_template_directory_uri() . '/js/columnizers.js', array('jquery'), '', false      );

       wp_register_script('bxslider', get_template_directory_uri() . '/js/jquery.bxslider.min.js', array('jquery'), '', true );
       if(is_page('home')) {

       wp_register_script('bootstrap', get_template_directory_uri() . '/js/vendor/bootstrap.min.js', array('jquery'), '', true );

       wp_register_script('plugins', get_template_directory_uri() . '/js/plugins.js', array('jquery'), '', true );

       wp_register_script('stickem', get_template_directory_uri() . '/js/jquery.stickem.js', array('jquery'), '', true );

       wp_enqueue_script('imageloader', get_template_directory_uri() . '/js/imagesloaded.pkgd.min.js',     array('jquery'), '', true );

2 Answers

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

If it's working it may be fine :)

Pinging Zac Gordon for sanity check.

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

First, you don't have to worry about calling jQuery. If you say a JS file is dependent on jQuery it will load it automatically.

Second, you don't have to use the wp_enqueue_script twice. It is used in conjunction with wp_register_script. Check out this video: http://teamtreehouse.com/library/how-to-build-a-wordpress-theme/preparing-to-code-wordpress-templates/linking-javascript-2