【问题标题】:Anchor Link to WooCommerce Reviews锚链接到 WooCommerce 评论
【发布时间】:2018-03-29 04:22:00
【问题描述】:

向下滚动到“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>

Link to Product

我检查了链接是否显示了正确的锚点,即 Link to Review Tab

【问题讨论】:

    标签: php jquery html wordpress woocommerce


    【解决方案1】:

    这是因为评论 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>
    

    【讨论】:

    • 此更改会使其滚动,但不会打开评论标签 - 它会打开“描述”标签?
    • 我告诉过你,你需要一个自定义的js代码来实现这个
    猜你喜欢
    • 1970-01-01
    • 2018-02-08
    • 2014-07-27
    • 1970-01-01
    • 1970-01-01
    • 2012-01-07
    • 1970-01-01
    • 2016-12-28
    • 1970-01-01
    相关资源
    最近更新 更多