Thanks in advance for any help you can provide. I am trying to implement raty.js into a archive template for a custom post type I have created. As far as I understand I only need to enqueue the jquery.raty.js file and jquery.raty.css files. So I have on my child theme functions.php

function jose_scripts() {
  wp_enqueue_style( 'raty-css', get_stylesheet_directory() . '/raty/lib/jquery.raty.css' );
  wp_register_script( 'raty-js', get_stylesheet_directory() . '/raty/lib/jquery.raty.js', array('jquery'),false,true);
add_action( 'wp_enqueue_scripts', 'jose_scripts' );

I sent it to the footer so it would load waaaaay after JQuery, still I get JQuery is not defined when I put

JQuery('div').raty({ score: 3 });

I see the jquery.raty.js file being called on the footer. And the JQuery.js on the head. I used JQuery because $ gives me the same error. The odd thing as well is that jquery.raty.js is also giving this error Uncaught

SyntaxError: Unexpected token < travelgfs.com/:259 Uncaught TypeError: $ is not a function

  • get_stylesheet_directory is the server path, you want get_stylesheet_directory_uri.
    – Milo
    Sep 18, 2015 at 19:49
  • Ok I changed to directory_uri but I am still getting JQuery is not defined but thank you for correcting that. If it helps this is the link to the page I am trying to correct travelgfs.com/testimonials
    – jsrosas
    Sep 18, 2015 at 20:01
  • your theme looks like it's including multiple copies of jquery. you also need to wrap your code in a document.ready handler, and it should be enqueued after your script and not directly within the content.
    – Milo
    Sep 18, 2015 at 20:15

1 Answer 1


It's jQuery not JQuery.

Try jQuery('div').raty({ score: 3 });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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