If you want to display unique content, banners (like the above image), ads, or anything after a set number of products, you can use the code below for assistance.
{%- assign product_counter = 0 -%}
{%- for result in collection.products -%}
{% if result.object_type == 'product' %}
{% assign mod_val = product_counter | modulo: 8 %}
{% if product_counter != 0 %}
{% if mod_val == 0 %}
<div class="unique-content">Break after 8 Product Card</div>
{% endif %}
{% endif %}
<div>Single Product Card</div>
{% endif %}
{%- assign product_counter = product_counter | plus: 1 %}
{%- endfor -%}
Change the number “8” with your desired number or make it dynamic.
That’s all 🙂