Wordpress 如果产品中没有评论,则显示分级

Wordpress 如果产品中没有评论,则显示分级,wordpress,woocommerce,hook-woocommerce,Wordpress,Woocommerce,Hook Woocommerce,我想在产品中没有可用评论时显示评级 当至少有一个评论可用时,当前显示评级 谢谢, 拉杰什·索兰基请使用此代码。 add_filter('woocommerce_product_get_rating_html','bb_woocommerce_product_get_rating_html',10,3); function bb_woocommerce_product_get_rating_html($html, $rating, $count){ if ( 0 == $rating ) {

我想在产品中没有可用评论时显示评级

当至少有一个评论可用时,当前显示评级

谢谢, 拉杰什·索兰基

请使用此代码。
add_filter('woocommerce_product_get_rating_html','bb_woocommerce_product_get_rating_html',10,3);

function bb_woocommerce_product_get_rating_html($html, $rating, $count){

if ( 0 == $rating ) {
    $html  = '<div class="star-rating">';
    $html .= wc_get_star_rating_html( $rating, $count );
    $html .= '</div>';
}
return $html;
add_filter('woocommerce_product_get_rating_html','bb_woocommerce_product_get_rating_html',10,3)

函数bb\u商业\u产品\u获取\u评级\u html($html,$rating,$count){

if(0==$rating){
$html='';
$html.=wc_get_star_rating_html($rating,$count);
$html.='';
}
返回$html;

}

希望您至少尝试自己编写代码。我建议你做一些额外的研究,要么通过谷歌,要么通过搜索,然后尝试一下。如果您仍然有问题,请返回您的代码,并解释您在原始问题中尝试了什么。