[英]Anchor Link to WooCommerce Reviews
向下滚动到“ Woocommerce评论选项卡”的锚链接无法正常工作。
<div class="woocommerce-product-rating">
<?php echo wc_get_rating_html( $average, $rating_count ); ?>
<?php if ( comments_open() ) : ?><a href="#tab-reviews" class="woocommerce-review-link" rel="nofollow">(<?php printf( _n( '%s customer review', '%s customer reviews', $review_count, 'woocommerce' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?>)</a><?php endif ?>
</div>
我检查了链接是否显示了正确的锚点,即“ 链接到审阅”选项卡
这是因为评论div被隐藏了。 如果您先单击“评论”标签,然后单击链接,它将起作用。
我认为您需要链接到ID为“ tab-title-reviews”的评论标签
<div class="woocommerce-product-rating">
<?php echo wc_get_rating_html( $average, $rating_count ); ?>
<?php if ( comments_open() ) : ?><a href="#tab-title-reviews" class="woocommerce-review-link" rel="nofollow">(<?php printf( _n( '%s customer review', '%s customer reviews', $review_count, 'woocommerce' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?>)</a><?php endif ?>
</div>
<script>
jQuery('.woocommerce-review-link').click(function(){
jQuery('#tab-title-reviews a').trigger('click');
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.