<p><a href="http://buildwithcraft.com/docs/templating/entrymodel#getPrev" rel="nofollow">getPrev</a>, <a href="http://buildwithcraft.com/docs/templating/entrymodel#getNext" rel="nofollow">getNext</a>, <a href="http://buildwithcraft.com/docs/templating/entrymodel#getPrevSibling" rel="nofollow">getPrevSibling</a>, <a href="http://buildwithcraft.com/docs/templating/entrymodel#getNextSibling" rel="nofollow">getNextSibling</a> all specify an entry relative to the current one. <code>prevChild</code> and <code>nextChild</code> if they existed would somehow specify an entry relative to a child of the current entry. They don't exist.</p>

<p>What you can do is paginate through the children. Here I use <code>.limit(1)</code> to page through them one at a time, but you could fetch more.</p>

<pre><code>{% set prePaginatedEntries = entry.getChildren().limit(1) %}
{% paginate prePaginatedEntries as entries %}
  {% for oneChild in entries %}
    {# do whatever with oneChild #}
  {% endfor %}
  {# pagination links #}
  {% if paginate.prevUrl %}
    &lt;a href="{{ paginate.prevUrl }}"&gt;Previous Page&lt;/a&gt;
  {% endif %}

  {% if paginate.nextUrl %}
    &lt;a href="{{ paginate.nextUrl }}"&gt;Next Page&lt;/a&gt;
  {% endif %}
{% endpaginate %}
</code></pre>

CC BY-SA 3.0
2014-07-17T12:59:21.110Z
2014-07-17T12:59:21.110Z
Marion Newlevant
<p>There is no <code>getPrevChild</code> and <code>getNextChild</code> methods, but the <code>getPrevSibling</code> and <code>getNextSibling</code> should still serve your purpose. You would simply call it on the child entry instead of its parent.</p>

<p>Another method would be to gather all the children in one go and paginate them via JavaScript.</p>

<p>And yet another method would be the <a href="http://buildwithcraft.com/docs/templating/tags#paginate" rel="nofollow"><code>paginate</code></a> tag. <code>paginate</code> works using any criteria. When you use <code>getChildren</code>, you are getting criteria that's used to pull the child entries.</p>

<pre><code>{% paginate entry.getChildren().limit(1) as entries %}
</code></pre>

<p>As per the docs, you would then get the <code>paginate.prevUrl</code> and <code>paginate.nextUrl</code> variables to page through as needed.</p>

CC BY-SA 3.0
2014-07-17T13:42:18.927Z
Hi Bryan, ref. your first option how would I get the child entry instead of its parent?
Gareth
CC BY-SA 3.0
2014-07-17T13:48:21.640Z
`entry.getChildren().first()`

All references to entries, assets, categories, etc. is just that: references. They don't contain the actual elements, but an ElementCriteriaModel that can pull those elements. In this case, the children of your parent entry.
Bryan Redeagle
CC BY-SA 3.0
2014-07-17T13:57:41.133Z
Bryan, please see my code update - it doesn't work, sorry I have probably misunderstood.
Gareth
CC BY-SA 3.0
2014-07-17T14:01:42.643Z
It's `getNextSibling` and `getPrevSibling`. You forgot the `get` in the method name. Also, you should think about how your urls will look. This might send you to the sibling's full page which will need to handle the parent differently that how you seem to have in this example.
Bryan Redeagle
CC BY-SA 3.0
2014-07-17T14:08:24.297Z
`entry.getChildren().first().prevSibling()` is never going to find anything - you are asking for the one before the first one.
Marion Newlevant
CC BY-SA 3.0
2014-07-17T14:22:15.697Z
This is true. Based on your example above I would suggest using `paginate` instead. It would keep the parent entry on each page that way. You may have to set up a route for it to work, but I'm not positive on that.
Bryan Redeagle
CC BY-SA 3.0
2014-07-17T14:48:51.663Z
Thank you will look at Marion's `paginate` option next.
Gareth
CC BY-SA 3.0
2014-07-17T13:03:48.717Z
2014-07-17T13:03:48.717Z
Bryan Redeagle
<p>I am trying to figure out how to page through only the children of the top level section entry being displayed, I have looked at <a href="https://craftcms.stackexchange.com/questions/333/how-do-you-page-through-entries-in-a-structure/334#334">this question</a> but as I say I am after only the children not the siblings.</p>

<p>Is there a <code>prevChild()</code> and <code>nextChild()</code> or something similar I can't see them in the <a href="http://buildwithcraft.com/docs/templating/entrymodel#methods" rel="nofollow noreferrer">docs</a>.</p>

<p><strong>Response to Bryan</strong></p>

<p>So I would do something like:</p>

<pre class="lang-twig prettyprint-override"><code>{% set prevDatabyteSeries = entry.getChildren().first().getPrevSibling() %}
{% set nextDatabyteSeries = entry.getChildren().first().getNextSibling() %}

{% if prevDatabyteSeries %}
&lt;a href="{{ prevDatabyteSeries.url }}" class="icon-alone paginate-arrow"&gt;
  &lt;i class="icon-arrow-left"&gt;&lt;/i&gt;
&lt;/a&gt;
{% endif %}

{% if nextDatabyteSeries %}
&lt;a href="{{ nextDatabyteSeries.url }}" class="icon-alone paginate-arrow"&gt;
  &lt;i class="icon-arrow-right"&gt;&lt;/i&gt;
&lt;/a&gt;
{% endif %}
</code></pre>

<sections><previous-next>
How do you page through child entries in a structure?
# How do you page through child entries in a structure?

(Asked by: username_0 on 2014-07-17)

I am trying to figure out how to page through only the children of the top level section entry being displayed, I have looked at this question but as I say I am after only the children not the siblings.
Is there a prevChild() and nextChild() or something similar I can't see them in the docs.
Response to Bryan
So I would do something like:
{% set prevDatabyteSeries = entry.getChildren().first().getPrevSibling() %}
{% set nextDatabyteSeries = entry.getChildren().first().getNextSibling() %}

{% if prevDatabyteSeries %}

  

{% endif %}

{% if nextDatabyteSeries %}

  

{% endif %}

**Tags:** sections, previous-next

---

## 2 answers

### Answer by username_1 on 2014-07-17. Score: 3 | Accepted answer

getPrev, getNext, getPrevSibling, getNextSibling all specify an entry relative to the current one. prevChild and nextChild if they existed would somehow specify an entry relative to a child of the current entry. They don't exist.
What you can do is paginate through the children. Here I use .limit(1) to page through them one at a time, but you could fetch more.
{% set prePaginatedEntries = entry.getChildren().limit(1) %}
{% paginate prePaginatedEntries as entries %}
  {% for oneChild in entries %}
    {# do whatever with oneChild #}
  {% endfor %}
  {# pagination links #}
  {% if paginate.prevUrl %}
    Previous Page
  {% endif %}

  {% if paginate.nextUrl %}
    Next Page
  {% endif %}
{% endpaginate %}


---

### Answer by username_2 on 2014-07-17. Score: 1

There is no getPrevChild and getNextChild methods, but the getPrevSibling and getNextSibling should still serve your purpose. You would simply call it on the child entry instead of its parent.
Another method would be to gather all the children in one go and paginate them via JavaScript.
And yet another method would be the paginate tag. paginate works using any criteria. When you use getChildren, you are getting criteria that's used to pull the child entries.
{% paginate entry.getChildren().limit(1) as entries %}

As per the docs, you would then get the paginate.prevUrl and paginate.nextUrl variables to page through as needed.

> **Comments:**
> **username_0**: Hi Bryan, ref. your first option how would I get the child entry instead of its parent?  
> **username_2**: `entry.getChildren().first()`  All references to entries, assets, categories, etc. is just that: references. They don't contain the actual elements, but an ElementCriteriaModel that can pull those elements. In this case, the children of your parent entry.  
> **username_0**: Bryan, please see my code update - it doesn't work, sorry I have probably misunderstood.  
> **username_2**: It's `getNextSibling` and `getPrevSibling`. You forgot the `get` in the method name. Also, you should think about how your urls will look. This might send you to the sibling's full page which will need to handle the parent differently that how you seem to have in this example.  
> **username_1**: `entry.getChildren().first().prevSibling()` is never going to find anything - you are asking for the one before the first one.  
> **username_2**: This is true. Based on your example above I would suggest using `paginate` instead. It would keep the parent entry on each page that way. You may have to set up a route for it to work, but I'm not positive on that.  
> **username_0**: Thank you will look at Marion's `paginate` option next.  

---

