• Hi all,

    I know this has probably been asked once too many, but it seems in the newest version i cannot get it to work for no reason. I am trying to load jquery, the version included in wordpress, in my custom theme so i can run jquery code without having to rely to my own version or a cdn file.

    I tried all different suggested methods. Not adding anything to my code and expecting it to work, such as

    wp_enqueue_script( 'jquery' );

    OR

    function loadScripts() {
        wp_enqueue_script( 'jquery' );
    wp_register_script('jqueryCycle',get_template_directory_uri().'/js/jquery.cycle.js', 'jquery');
        wp_enqueue_script( 'jqueryCycle' );
        wp_register_script('javascript', get_template_directory_uri().'/js/javascript.js', 'jquery');
        wp_enqueue_script( 'javascript' );
    wp_register_script('jqueryCookie', get_template_directory_uri().'/js/jquery.cookie.js', 'jquery');
        wp_enqueue_script( 'jqueryCookie' );
        wp_register_script('jqueryCookiecuttr', get_template_directory_uri().'/js/jquery.cookiecuttr.js', 'jquery' );
        wp_enqueue_script( 'jqueryCookiecuttr' );
    }
    
    add_action( 'wp_enqueue_scripts', 'loadScripts' );  (code i got from older theme, same errors)

    OR

    function td_load_js() {
        wp_enqueue_script( 'jquery' );
        wp_enqueue_script( 'javascript', get_template_directory_uri() . '/js/javascript.js', array( 'jquery' ), 1, false);
    } add_action('init', 'td_load_js'); (in fuctions.php, still same errors)

    No matter what version of the above i use, i always get the “$ is not available” or “jQuery is not available”. I have code that is using both $ and jQuery as the jquery object so i can see which solution works with which object but none of the above examples will work with either object.. any help?

    Thanks!

  • The topic ‘Problems loading jQuery in my custom themes’ is closed to new replies.