i want to write code for checking whether for loop.index is divisible by 10 or not in shopify

enter image description here when I write this code {% if forloop.index % 10 == 0 %} why it is showing error? Please Help {% if forloop.index % 10 == 0 %} <div class="banner"> <p>This is a banner displayed after every 10 products!</p> </div> {% endif %} I've tried this code but it is not working Please help

Comment (1)

Jese Leos

September 27, 2024

Verified user

I don't know much about shopify, but have you tried running the code like this? {% assign remainder = forloop.index | modulo:10 %} {% if remainder == 0 %} <div class="banner"> <p>This is a banner displayed after every 10 products!</p> </div> {% endif %}

You’ll be in good company