to get pages as array use get_pages()
instead. now once we have a list we can check the size of list and split it. Let’s have an example:
$allpages = get_pages(
array(
'child_of' => $section_top_parent,
'post_type' => 'section',
'depth' => 1,
'sort_order' => 'asc'
)
);
//check $allpages has any value
if($allpages){
//calculate the array size
$totalSize = sizeof($allpages);
//now divide the array
$firstFour = array_slice($allpages, 0, 4);
$rest = array();
//Check if the array has more than 4 items.
if($totalSize > 4){
//As we already got first for so we only need the rest of the pages.
$rest = array_slice($allpages, 4, $totalSize-4 );
}
//now you can loop through both $firstFour & $rest to show them as you like.
}
You can a do foreach
loop to present the items in your custom htlm.