I’m getting the result, but I think something is not closing right. When I duplicate that code again for another menu like copy paste that code just beneath it, the layout turns to be so wrong. Can anyone please explain why? I’m fairly new to Liquid and Shopify Theme dev..
Do not look at “inspect element”, check the “view source” as browsers tend to tolerate things like this and will supply closing to fix it themselves, but you never know how intelligent the browser is.
I’d use one of those two codes instead – similar to yours:
{% for link in section.settings.shop_workwear_menu.links %}
{% assign r = forloop.index0 | modulo: 8 %}
{% if r == 0 %}
{% endif %}
{{ link.title }}
{% if r == 7 or forloop.last %}
{% endif %}
{% endfor %}
or a bit different:
{% for link in section.settings.shop_workwear_menu.links %}
{% assign r = forloop.index0 | modulo: 8 %}
{{ link.title }}
{% if r == 7 and forloop.last == false %}
{% endif %}
{% endfor %}