Need a little help with a couple lines of php
template-tags.php around line 444
I am looking to only show the ratings if there is a rating or one where the rating is 1 or greater else show nothing.
I am totally crap at php, I tried a couple things but noting really worked, any help will be greatly appreciated.
/**
* Displays listing star rating.
*
* @param int $post_id (optional)
*
* @return void
*/
function the_listing_star_rating( $post_id = '' ) {
$rating = str_replace( '.', '_', va_get_rating_average( $post_id ) );
if ( '' == $rating ) {
$rating = '0';
}
?>
<div class="stars-cont">
<div class="stars stars-<?php echo $rating; ?>"></div>
</div>
<meta itemprop="worstRating" content="1" />
<meta itemprop="bestRating" content="5" />
<meta itemprop="ratingValue" content="<?php echo esc_attr( $rating ); ?>" />
<meta itemprop="reviewCount" content="<?php echo esc_attr( va_get_reviews_count( $post_id ) ); ?>" />
<?php
}
So only when there is a star rating of 1 or above show:
<div class="stars-cont">
<div class="stars stars-<?php echo $rating; ?>"></div>
</div>
<meta itemprop="worstRating" content="1" />
<meta itemprop="bestRating" content="5" />
<meta itemprop="ratingValue" content="<?php echo esc_attr( $rating ); ?>" />
<meta itemprop="reviewCount" content="<?php echo esc_attr( va_get_reviews_count( $post_id ) ); ?>" />