Looping and Iteration

Created by Fawzia Aleem, Modified on Tue, 18 Jun, 2024 at 4:43 PM by Fawzia Aleem

You can iterate through HTML or liquid code by using the For loop. Loops are especially useful for things like running through and displaying all the solutions under a specific folder.


Syntax:

 

{% for item in array %}{% endfor %}


You can also limit the number of iterations by using the limit parameter. 

{% for folder in category.folders limit: 6 %}

{% endfor %}


There are times when you want to start looping from the second, fifth or the n’th item in your list. You can do this using the offset parameter.


{% for forum in portal.forums offset: 2 %}

{% endfor %}



Next: Assigning Variables 

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article