Add paging support to get_pages(). Fixes #4531 props DD32.

git-svn-id: http://svn.automattic.com/wordpress/trunk@11251 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-05-10 08:55:49 +00:00
parent e61bea89ed
commit 9e32b2810a
1 changed files with 7 additions and 1 deletions

View File

@ -2193,11 +2193,14 @@ function &get_pages($args = '') {
'sort_column' => 'post_title', 'hierarchical' => 1,
'exclude' => '', 'include' => '',
'meta_key' => '', 'meta_value' => '',
'authors' => '', 'parent' => -1, 'exclude_tree' => ''
'authors' => '', 'parent' => -1, 'exclude_tree' => '',
'number' => '', offset => '0'
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$number = (int) $number;
$offset = (int) $offset;
$cache = array();
$key = md5( serialize( compact(array_keys($defaults)) ) );
@ -2295,6 +2298,9 @@ function &get_pages($args = '') {
$query .= $author_query;
$query .= " ORDER BY " . $sort_column . " " . $sort_order ;
if ( !empty($number) )
$query .= ' LIMIT ' . $offset . ',' . $number;
$pages = $wpdb->get_results($query);
if ( empty($pages) ) {