Select first number of subpages

Hi, is there a way to select a few subpages by their position? For example, select first 5 pages or select pages 6 onwards?

Here’s the what I am trying to do. Thanks.

<ul class="top_block">
<?php
$topItems = $data->children()->listed(); //select only the first 5 pages
foreach ($topItems as $topItem): ?> 

	<li class="items_one_to_five">
		<a href="<?= $topItem->link() ?>">
		</a>
	</li>

<?php endforeach ?>
</ul>

<ul class="bottom_block">
<?php
$items = $data->children()->listed(); //select all the rest
foreach ($items as $item): ?> 

	<li class="items_six_on">
		<a href="<?= $item->link() ?>">
		</a>
	</li>

<?php endforeach ?>
</ul>

You can use limit() and offset() methods:

$data->children()->listed()->limit(5); // Get top 5 items

$data->children()->listed()->offset(5); //  Get items after 5 offset

Thanks!
offset() works great! but nth(5) returns an error. Any idea why?

Ahh sorry, you need use limit() method like that:

$data->children()->listed()->limit(5); // Get top 5 items

That works perfect! Thanks!

You can look out other incredible $pages collection methods from here: