Title: Nested &#039;for loop&#039; index
Last modified: August 30, 2016

---

# Nested 'for loop' index

 *  Resolved [NSC Creative](https://wordpress.org/support/users/nsc-creative/)
 * (@nsc-creative)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/nested-for-loop-index/)
 * Hi there,
 * I have a nested ‘for loop’ to return post with the tag ‘featured’ and need to
   limit the results to just the most recent. The outer loop is returning the correct
   index with {{ loop.index }} but the inner one only returns the result ‘1’.
 *     ```
       {% for post in posts %}
         {% for term in post.terms('tags') if term.name|lower == 'featured' %}
   
              {{ loop.index }}
   
         {% endfor %}
       {% endfor %}
       ```
   
 * Any help on or alternate other ways to implement this would be great!
 * [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)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/nested-for-loop-index/#post-6813819)
 * Hi [@nsc-creative](https://wordpress.org/support/users/nsc-creative/)! Please
   post questions on StackOverflow:
 * [http://stackoverflow.com/questions/tagged/timber](http://stackoverflow.com/questions/tagged/timber)
 * … this way it makes it easier to share answers, tips and up-vote what works (
   oh and Google to find it all). Thanks for using Timber!

Viewing 1 replies (of 1 total)

The topic ‘Nested 'for loop' index’ 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

 * [post](https://wordpress.org/support/topic-tag/post/)
 * [post loop](https://wordpress.org/support/topic-tag/post-loop/)

 * 1 reply
 * 2 participants
 * Last reply from: [jarednova](https://wordpress.org/support/users/jarednova/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/nested-for-loop-index/#post-6813819)
 * Status: resolved