Title: Counter in loop
Last modified: August 22, 2016

---

# Counter in loop

 *  Resolved [Geminiluv](https://wordpress.org/support/users/geminiluv/)
 * (@geminiluv)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/counter-in-loop/)
 * Hello,
 * I am just starting with timber/twig editing an existing view in a theme. I am
   having an issue with the counter in a loop. I have 2 tables being populated by
   the view pulling from an ACF form. The tbody in the loop starts with {% set counter
   = 1 %} and ends with {% set counter = counter + 1 %} at the end of the loop. 
   Problem is the second table populates the title field correctly but when it pulls
   the oEmbed fields from ACF it duplicates the same URLs from the first table instead
   of continuing the count of the oEmbed fields. Any help would be greatly appreciated.
   I been scouring forums and documentation but I cannot seem to find how to make
   it continue the count instead of starting over for the second table.
 * Thank you!
 * [https://wordpress.org/plugins/timber-library/](https://wordpress.org/plugins/timber-library/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [jarednova](https://wordpress.org/support/users/jarednova/)
 * (@jarednova)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/counter-in-loop/#post-5502239)
 * Hi [@geminiluv](https://wordpress.org/support/users/geminiluv/), this link from
   the Twig docs will help you get the value of the loop iteration without the manual
   counter hack:
 * [http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable](http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable)

Viewing 1 replies (of 1 total)

The topic ‘Counter in loop’ is closed to new replies.

 * ![](https://ps.w.org/timber-library/assets/icon-256x256.png?rev=1482054)
 * [Timber](https://wordpress.org/plugins/timber-library/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/timber-library/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/timber-library/)
 * [Active Topics](https://wordpress.org/support/plugin/timber-library/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/timber-library/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/timber-library/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)
 * [custom theme](https://wordpress.org/support/topic-tag/custom-theme/)

 * 1 reply
 * 2 participants
 * Last reply from: [jarednova](https://wordpress.org/support/users/jarednova/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/counter-in-loop/#post-5502239)
 * Status: resolved