The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Star Rating WordPress Issue

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #184882

    Hey guys,

    I am creating a star rating script to let users rate their experience at a restaurant, basically I want it so if a certain check-box is checked it shows a div. I have achieved this with:

    jQuery(‘.star’).click(function () {
    if ( == “rating5”) {
    } else {

    This works however, when I try and use it on my WordPress site, it does not run even with a simple alert, I know the coding is right. Additionally I have enqueued this script using

    function theme_name_scripts() {
    wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/form.js’, array(), ‘1.0.0’, true );
    add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ );

    I have viewed the source and its loading my JavaScript so why is nothing running? It’s my understanding that WordPress defaults with Jquery so that cannot be the issue. (my form is on a single WordPress page, single.php)

    In the end if you click the fifth star it will show a form I made with contact form 7.


    I don’t see nothing wrong with the script, and as you say, it does work outside of WordPress, so something must be interfering.

    But It’s hard to say what that could/would be without seeing the actual page in action.


    Thanks @Senff, turns out the problem was get_template_directory_uri I changed it to get_stylesheet_directory_uri and it worked!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.