Show selected category title from product categories

CPO0CCPO0C Member Posts: 3
edited November 2021 in Theme and Design

Hi, just got a simple question if

{% for category in product.categories %}

     <div> {{ category.title }} </div>

 {% endfor %}

shows all available category titles

How would I show only the first two category titles?

1 comment

  • larry_nalzarolarry_nalzaro Member Posts: 30

    Do it like this:

    {% for category in product.categories %}
        {% if loop.index < 3 %}
            <div> {{ category.title }} </div>
        {% endif %}
    {% endfor %}
    
Sign In or Register to comment.