【发布时间】:2020-08-07 06:00:45
【问题描述】:
我正在尝试向位于 content-widget-reviews.php 的 <div class="star-rating"> 添加一个类(在 woocommerce 模板中)
显示在这里:
<?php echo wc_get_rating_html( intval( get_comment_meta( $comment->comment_ID, 'rating', true ) ) ); ?>
我想让我的模板与 Bootstrap 4 一起工作(见下面的大写) float right needs to be removed 对比 wanted result
我在下面尝试了这个解决方案,但是它在整个模板上添加了类(我只想将这个类添加到小部件区域)
// Widget review Stars
function myfuntion_wc_get_rating_html($html) {
// Replace link classes
$html = str_replace('<div class="star-rating"', '<div class="star-rating float-none text-primary"', $html);
return $html;
}
add_filter("woocommerce_product_get_rating_html", "myfuntion_wc_get_rating_html")
;
有没有办法直接在这段代码上添加我的自定义类?
<?php echo wc_get_rating_html( intval( get_comment_meta( $comment->comment_ID, 'rating', true ) ) ); ?>
谢谢
附:我想避免使用 Jquery 和 CSS
【问题讨论】:
标签: php wordpress woocommerce bootstrap-4