2

I used the following to enqueue jquery plugins:

<?php
    function my_scripts_method() {
        wp_enqueue_script(
            'custom functions',
            get_template_directory_uri() . '/js/main.js',
            array('jquery'),
            '1',
            true
        );
        wp_enqueue_script(
            'dotdotdot & lightbox',
            get_template_directory_uri() . '/js/plugins.js',
            array('jquery'),
            '1',
            true
        );
    }
    add_action('wp_enqueue_scripts', 'my_scripts_method');

And I don't know it it's related but jquery only responds to calling jquery(... and not $(.... Why is that?

6

Use closure for your scripts:

(function($){
    $(document).ready(function() {
        // do something...
    });
})(jQuery);

It is safe way to use jQuery.

7

jQuery supplied with WordPress is in noConflict mode to avoid issues with other libraries that may use the $ as their object reference.

See wp_enqueue_script: jQuery noConflict wrappers for more info.

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.