首页 > 解决方案 > 标记过滤器到 Shopify

问题描述

我想根据前缀过滤标签。假设我的标签为 filter-material-woolen、filter-material-woolen1、filter-febric-velvet、filter-febric-velvet1。所以我必须过滤带有前缀“filter-”的标签,中间关键字如“material,febric”将作为标题,最终键将作为值。

<h1>material</h1>
<p>woolen1,woolen</p>

<h1>febric</h1>
<p>velvet,velvet1</p>

标签: shopifyshopify-appshopify-template

解决方案


<ul>
    {% for tag in collection.all_tags %}
        {% if tag contains 'filter-' %}
            <li>{{ tag | remove: 'filter-material-' | remove: 'filter-febric-' | link_to_tag: tag }}</li>
        {% endif %}
    {% endfor %}
</ul>

推荐阅读