# How is it best to loop 2 types of divs in wordpress?

**URL:** <https://forum.pinegrow.com/t/how-is-it-best-to-loop-2-types-of-divs-in-wordpress/5264>\
**Category:** WordPress\
**Tags:** wordpress\
**Created:** [May 11, 2021, 9:46am UTC](https://forum.pinegrow.com/t/how-is-it-best-to-loop-2-types-of-divs-in-wordpress/5264 "2021-05-11T09:46:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grimur](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@grimur](https://forum.pinegrow.com/u/grimur)\
**Post date:** [May 11, 2021, 9:46am UTC](https://forum.pinegrow.com/t/how-is-it-best-to-loop-2-types-of-divs-in-wordpress/5264/1 "2021-05-11T09:46:26Z")

</div>

Hi,  
I was wondering how to loop through 2 different divs/columns/rows  
Lets say I have the following rows:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/4/4a36c683734c4d350ceacc0c167b5be587a93c3f.png)

Is there an easy way to accomplish this? This is just an example. I’m looking to how to loop through more than 1 type of rows and columns

---

<div class="post-metadata">

**Author:** ![RobM](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@RobM](https://forum.pinegrow.com/u/RobM)\
**Post date:** [May 12, 2021, 1:36pm UTC](https://forum.pinegrow.com/t/how-is-it-best-to-loop-2-types-of-divs-in-wordpress/5264/2 "2021-05-12T13:36:35Z")

</div>

Hi @grimur,  
I don’t work with WordPress in Pinegrow enough to give a really great and simple answer. Partially it depends on your content. If you are just listing all or a selection of posts with a single query it is easier than if you need multiple queries.  
In the case of a single query I would likely accomplish this with some conditionals in PHP. Basically, you would have your divs wrapped in a conditional outer row added with a block of php code. Then the type of column would be added with a further conditional. Not sure how good it will display in Pinegrow.  
Alternatively, you could use straight CSS and an nth-of-type to add the style that would come from the Bootstrap class.  
Finally, you could do the same sort of thing with jQuery/JavaScript to add the class where you want it.  
I’ll think a little more to see if I can come up with a more “Pinegrowy” way of doing it.  
Cheers,  
Bob

---

<div class="post-metadata">

**Author:** ![grimur](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@grimur](https://forum.pinegrow.com/u/grimur)\
**Post date:** [May 15, 2021, 12:12am UTC](https://forum.pinegrow.com/t/how-is-it-best-to-loop-2-types-of-divs-in-wordpress/5264/3 "2021-05-15T00:12:33Z")

</div>

Ok great thanks for the reply. I have managed to loop through lets say latest 3 posts from a certain category. Then I loop only 1 with one column and then loop from second latest with next column but looping through all posts with this diffrent layouts I haven’t found out how from within pinegrow. Propably possible with php mix but was hoping to achieve this within pinegrow a simpler way.
