评级显示数字而不是星星

时间:2018-03-20 07:13:33

标签: wordpress schema.org rating

我不知道为什么我的网站的Schema.org标记显示数字和字符而不是星号。

例如,它显示“3/5”而不是“***”。

我该如何解决?

我正在使用WordPress和All In One Schema Rich Snippets插件。

1 个答案:

答案 0 :(得分:2)

遇到同样的问题。经过大量的搜索和试验,我想出了这个解决方案。

这将获得显示评级的模板。但它显示如下:Rated 4.50 out of 5 based on 2 customer ratings (2 customer reviews)

<div class="rating-custom">
    <?php wc_get_template( 'single-product/rating.php' ); ?>
</div>

然后将此css代码粘贴到自定义CSS中。

/*star rating for products*/
.rating-custom div.product .woocommerce-product-rating {
    margin-bottom: 1.618em;
}

.rating-custom .woocommerce-product-rating .star-rating {
    margin: .5em 4px 0 0;
    float: left;
}

.rating-custom .woocommerce-product-rating::after, .rating-custom .woocommerce-product-rating::before {

    content: ' ';
    display: table;

}

.rating-custom .woocommerce-product-rating {
    line-height: 2;
}

.rating-custom .star-rating {
    float: right;
    overflow: hidden;
    position: relative;
    height: 1em;
    line-height: 1;
    font-size: 1em;
    width: 5.4em;
    font-family: star;
}

.rating-custom .star-rating::before {
    content: '\73\73\73\73\73';
    color: #d3ced2;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
}

.rating-custom .star-rating {
    line-height: 1;
    font-size: 1em;
    font-family: star;
}

.rating-custom .star-rating span {
    overflow: hidden;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
    padding-top: 1.5em;
}

.rating-custom .star-rating span::before {
    content: '\53\53\53\53\53';
    top: 0;
    position: absolute;
    left: 0;
}

.rating-custom .star-rating span {

    overflow: hidden;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
    padding-top: 1.5em;

}

输出:

rating output