<p>If you're getting all the descendants in the for loop, you can use <code>loop</code> to get the index of the current iteration:</p>

<pre><code>{% for chapter in entry.descendants %}
    &lt;div class="part"&gt;&lt;span&gt;Part {{ loop.index | numbersToWords }}&lt;/span&gt;&lt;/div&gt;
{% endfor %}
</code></pre>

<p>See the <a href="http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable" rel="nofollow noreferrer">documentation for loop in the Twig docs</a> for more details.</p>

<p>This gives you the index of the current iteration in the for loop though, not the actual position of the child in the structure. So if you query only a subset of the descendants, or reorder and manipulate the descendants, this won't work.</p>

CC BY-SA 3.0
2016-11-14T21:38:02.647Z
Thanks André, that works nicely as each chapter has a subtitle and the part order number matches the Structure and the custom editor's (drag & drop) arrangement.
Nutmeg
CC BY-SA 3.0
2016-11-14T09:20:09.027Z
2016-11-14T09:27:19.537Z
2016-11-14T09:27:19.537Z
André Elvan
<p>I thought this was going to be easy; showing the order number of children against their parent, but the only answer I can find is in this <a href="https://craftcms.stackexchange.com/questions/13214/how-to-get-the-order-number-of-the-current-entry-in-a-structure">thread</a> </p>

<p>and I'm unsure how to implement this into my code.</p>

<pre><code>{% for chapter in entry.descendants %}
&lt;div class="part"&gt;&lt;span&gt;Part {{ chapter.orderNumber | numbersToWords }}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;                      
{% endfor %}
</code></pre>

<p>Resulting in: <strong>Part One</strong></p>

<p>Note: <code>numbersToWords</code> is the Helpers Plugin by <a href="https://github.com/carlcs/craft-helpers" rel="nofollow noreferrer">carlcs</a> </p>

<entries><order><children><number>
Display children's order numbers
# Display children's order numbers

(Asked by: username_0 on 2016-11-14)

I thought this was going to be easy; showing the order number of children against their parent, but the only answer I can find is in this thread 
and I'm unsure how to implement this into my code.
{% for chapter in entry.descendants %}
Part {{ chapter.orderNumber | numbersToWords }}
                      
{% endfor %}

Resulting in: Part One
Note: numbersToWords is the Helpers Plugin by carlcs

**Tags:** entries, order, children, number


---

## 1 answers

### Answer by username_1 on 2016-11-14. Score: 1 | Accepted answer

If you're getting all the descendants in the for loop, you can use loop to get the index of the current iteration:
{% for chapter in entry.descendants %}
    Part {{ loop.index | numbersToWords }}
{% endfor %}

See the documentation for loop in the Twig docs for more details.
This gives you the index of the current iteration in the for loop though, not the actual position of the child in the structure. So if you query only a subset of the descendants, or reorder and manipulate the descendants, this won't work.

> **Comments:**
> **username_0**: Thanks André, that works nicely as each chapter has a subtitle and the part order number matches the Structure and the custom editor's (drag & drop) arrangement.  

---

