• Resolved mazikeen

    (@mazikeen)


    I’ve tried the code below but it doesn’t show the correct average vote. It only shows a 0 digit.

    <?php if(function_exists('the_ratings')) { the_ratings(); } ?>
    <?php echo intval( get_post_meta($post_id, 'ratings_average', true ) ); ?>

    The star rating is working. After i click the star & rate it shows the correct values:
    (2 votes, average: 3.00 out of 5, rated)

    but i using the get_post_meta ratings_average, it just gives me a “0” digit.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Lester Chan

    (@gamerz)

    That is because you are using intval() which cast it. You do not need to intval()

    Thread Starter mazikeen

    (@mazikeen)

    I removed the Intval and the 0 disappears but the average vote still doesn’t shows up.

    <?php if(function_exists('the_ratings')) { the_ratings(); } ?>
    <?php echo  get_post_meta($post_id, 'ratings_average', true ) ; ?>

    Could you give me example codes for displaying average votes & total votes?
    Im not really a coder so im kinda confused. Im just trying to add it to a theme i bought.

    Thanks!

    Plugin Author Lester Chan

    (@gamerz)

    I got a feeling you did not assign $post_id.

    <?php echo get_post_meta( get_the_ID(), 'ratings_average', true ) ; ?> gives you average.
    <?php echo get_post_meta( get_the_ID(), 'ratings_users', true ) ; ?> gives you total vote.

    Thread Starter mazikeen

    (@mazikeen)

    thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to display average votes in posts?’ is closed to new replies.