Return star count

This topic contains 4 replies, has 3 voices, and was last updated by  Berto 5 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #517821

    Berto
    Expired Member
    Post count: 53

    Is there a way to return the average star count?

    I want to add a custom class based on the number of stars each listing has. I had originally done this based on the number of comments by doing the following:

    
    function listing_has_reviews( $classes, $class, $post_ID ) {
        global $gd_post;
        $reviewcount = get_comments_number();
     
        if($reviewcount > 0 ) {
            $classes[] = 'gd-has-1-review'; 
        }
        return $classes;
    }

    However, I am seeing that (for my purposes) this will not work so I instead need to return the number of stars.

    Any pointers would be appreciated.

    And apologies (in advance) if I have posted this in the wrong forum.

    #517827

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    I will flag your topic for the developers and they will comment if they can offer any pointers.

    #517840

    Berto
    Expired Member
    Post count: 53

    Thank you Alex.

    #518056

    Naveen Giri
    Moderator
    Post count: 1559

    Hi Berto,

    you can use below function.

    
    geodir_reviewrating_get_post_rating( $post_id );
    

    Thanks

    #518308

    Berto
    Expired Member
    Post count: 53

    That didn’t work.

    This worked.

    geodir_get_post_rating( $post->ID );

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount