<pre><code>{% if loop.index is divisible by(2) %}stuff{% else %}other-stuff{% endif %}
</code></pre>

CC BY-SA 3.0
2016-08-18T19:32:01.313Z
2016-08-18T19:32:01.313Z
AbbeyDesign
<p>How do you template to output across a grid that switches between vertical and horizontal posts?  I left the Craft/Trig off. </p>

<p>I know how to loop through and print entries using one orientation.  But how do I get it to change direction after every 2 and then switch back again, repeat...</p>

CC BY-SA 3.0
2016-08-18T19:10:15.610Z
It's very hard to tell what you are looking for here... This seems more like a CSS or responsive design question, unless I'm misunderstanding?
Lindsey D
CC BY-SA 3.0
2016-08-18T19:23:39.980Z
I did not add the Craft/Twig to this example.  Let me try again, I know how to get Craft to repeat one orientation - for example, just horizontal by repeating the mark-up for (in this case) the horizontal entry.  But, how do I get it to loop through the entries and at the same time switch every 2 between horizontal and then vertical.
Hellyar
CC BY-SA 3.0
2016-08-18T19:29:14.800Z
I would recommend two things to improve this question... (1) Get rid of all extraneous markup (you have tons of classes and extra markup which is distracting from your basic architecture), and (2) **include the Twig code that you already know how to use.** It is much easier for other people to _improve_ on your existing Twig code, rather than expecting them to write the entire thing for you.
Lindsey D
<templating>
How to Template Grid for Entries that Switch from Horizontal to Vertical?
# How to Template Grid for Entries that Switch from Horizontal to Vertical?

(Asked by: username_0 on 2016-08-18)

How do you template to output across a grid that switches between vertical and horizontal posts? I left the Craft/Trig off.

I know how to loop through and print entries using one orientation. But how do I get it to change direction after every 2 and then switch back again, repeat...

**Tags:** templating

> **Comments:**
> **username_1**: It's very hard to tell what you are looking for here... This seems more like a CSS or responsive design question, unless I'm misunderstanding?  
> **username_0**: I did not add the Craft/Twig to this example.  Let me try again, I know how to get Craft to repeat one orientation - for example, just horizontal by repeating the mark-up for (in this case) the horizontal entry.  But, how do I get it to loop through the entries and at the same time switch every 2 between horizontal and then vertical.  
> **username_1**: I would recommend two things to improve this question... (1) Get rid of all extraneous markup (you have tons of classes and extra markup which is distracting from your basic architecture), and (2) **include the Twig code that you already know how to use.** It is much easier for other people to _improve_ on your existing Twig code, rather than expecting them to write the entire thing for you.  

---

## 1 answers

### Answer by username_2 on 2016-08-18. Score: 3 | Accepted answer

{% if loop.index is divisible by(2) %}stuff{% else %}other-stuff{% endif %}


---

