• Resolved josemiss

    (@josemiss)


    i try to insert my rate result in portfolio, but if the page has not been voted it doesn’t show a rate, is there a way to use a default?

    i use these:
    <div id=”RatedStarPortfolio”><?php echo Rate_My_Post_Public_Helper::get_visual_rating() .” “. rmp_get_avg_rating( get_the_ID() ) .” (“. rmp_get_vote_count( get_the_ID() ) . “)” ?></div>

    <div id=”RatedStarPortfolio1″><?php echo Rate_My_Post_Public_Helper::get_visual_rating( ) .” “. rmp_get_avg_rating( ) .” (“. rmp_get_vote_count( ) . “)” ?></div>

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support Blaz K.

    (@blazk)

    Hi @josemiss,

    these functions all return false if the article hasn’t been rated yet. You can check and act on false. See example below:

    
    <div id=”RatedStarPortfolio”>
      <?php
        $visualRating = Rate_My_Post_Public_Helper::get_visual_rating();
        $votes = rmp_get_vote_count( get_the_ID() );
        $rating =  rmp_get_avg_rating( get_the_ID() );
    
        if( !$visualRating ) {
          $visualRating = str_repeat( '<i class="fa fa-star fa-fw"></i>', 5 );
        }
    
        if( !$votes ) {
    	$votes = '0';
        }
    
        if( !$rating ) {
    	$rating = '0';
        }
    
        echo $visualRating . ' ' . $rating .' ('. $votes . ')';
      ?>
    </div>
    

    Hope this was helpful.

    Regards,
    Blaz

Viewing 1 replies (of 1 total)
  • The topic ‘doesn’t show star’ is closed to new replies.