最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

woocommerce offtopic - Anchor link to every product

programmeradmin1浏览0评论

I use WooCommerce on WordPress. Now when I click (open) some product I have to scroll down lot, because there is long header and menu before product itself.

So, my question is: How to add anchor to product link when I click (open) it?

If you don't understand, please ask me.

I use WooCommerce on WordPress. Now when I click (open) some product I have to scroll down lot, because there is long header and menu before product itself.

So, my question is: How to add anchor to product link when I click (open) it?

If you don't understand, please ask me.

Share Improve this question edited Jun 8, 2019 at 8:32 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Jun 8, 2019 at 7:17 JuusoJuuso 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

You can use the woocommerce_loop_product_link filter to modify the archive product urls.

// Add to (child) theme functions.php
function my_prefix_modify_woocommerce_loop_product_link( $url, $product ) {
  /**
    * Adds the id of the product wrap element from single product view
    * as an anchor parameter to the WooC archive loop product url
    * e.g. http://www.mystore/my-product#single-produt-wrap-id
    * update "single-produt-wrap-id" to match your setup
    */
  return $url . "#single-produt-wrap-id";
}
add_filter( 'woocommerce_loop_product_link', 'my_prefix_modify_woocommerce_loop_product_link', 10, 2 );
发布评论

评论列表(0)

  1. 暂无评论