I am trying to figure out how to index specific product titles (first, second, third etc.) within a collection. I have written the code below - however it just prints the first letter of each product within that collection, instead the entire title of the first product:
{% for product in collections.frontpage.products %}
{{ product.title | first }}
{% endfor %}
Any ideas on how I can get the full title, and any iteration (the second or third product in the array) ?
Hi @jakebatic ,
I don’t really understand your question, but you can refer to the following code:
{% for product in collections.frontpage.products %}
- {{ forloop.index }} - {% if forloop.first == true %}{{ product.title | upcase }}{% else %}{{ product.title }}{% endif %}
{% endfor %}
You can refer to the following 2 instructions:
https://shopify.dev/api/liquid/objects/for-loops#forloop-index
https://shopify.dev/api/liquid/filters/string-filters#upcase
Hope it helps!