shopify产品页获取产品所属分类liquid代码

我们在shopify产品页要自动调取产品所属分类,实现如下图的效果。

cb1480e5c07eff2e97a36244b3176437

如何不通过插件快速简单的实现这个功能呢。只需要在产品页插入下面的liquid代码即可。

<div class="categories">
<style>
.categories {
margin-top:20px;
}
</style> 
Categories: {% for collection in product.collections %}
<a href="{{ collection.url }}">{{ collection.title }}</a>,
{% endfor %}
</div>

具体插入方法:

1、shopify2.0主题为例。自定义主题-产品页模板。在需要的地方添加一个“Custom liquid”。输入上面的代码即可

13c5902714e1f36a58162de5ef07247a

2、shopify1.0需要进入模板代码编辑页面。在需要的区域黏贴

89770bbd856db7de9fb1a6aafb29de6f

此方法来自于shopify官方论坛

https://community.shopify.com/c/shopify-design/display-the-list-of-product-s-collections-on-a-product-page/td-p/1629929

评论0

显示验证码
我们将24小时内回复。
取消

Warning: error_log(/www/wwwroot/theme.shopupup.com/wp-content/plugins/spider-analyser/#log/log-2523.txt): failed to open stream: No such file or directory in /www/wwwroot/theme.shopupup.com/wp-content/plugins/spider-analyser/spider.class.php on line 3014