How can I limit the get_pages to only show 5 items?
I thought adding 'number' => 5
to the array would limit it to 5 but it doesn’t show anything. Here’s my code:
<?php
$pages = get_pages(array('post_type' => 'page','sort_column' => 'menu_order','sort_order' => 'ASC','child_of' => 765));
foreach($pages as $post)
{
setup_postdata($post);
$fields = get_fields();
?>
<p><?php echo $fields->start_date; ?> <a href="<?php echo get_page_link($post->ID) ?>"><?php echo substr($fields->event_title,0,24) . "..."; ?></a></p>
<?php
}
wp_reset_query();
?>
I have had similar problems with the
number
attribute inget_pages()
I got around it by using get_children:
and using
post_parent
instead ofchild_of
.