WordPress.org

Make WordPress Core

Ticket #4531: 4531.get_pages-limits

File 4531.get_pages-limits, 914 bytes (added by DD32, 7 years ago)

Adds numberpages and offset to get_pages

Line 
1Index: wp-includes/post.php
2===================================================================
3--- wp-includes/post.php        (revision 5740)
4+++ wp-includes/post.php        (working copy)
5@@ -1044,6 +1044,7 @@
6        global $wpdb;
7 
8        $defaults = array(
9+               'numberpages' => -1, 'offset' => 0,
10                'child_of' => 0, 'sort_order' => 'ASC',
11                'sort_column' => 'post_title', 'hierarchical' => 1,
12                'exclude' => '', 'include' => '',
13@@ -1125,6 +1126,8 @@
14        $query .= ( empty( $meta_key ) | empty($meta_value)  ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ;
15        $query .= $author_query;
16        $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
17+       if ( 0 < $numberpages )
18+               $query .= " LIMIT " . $offset . ',' . $numberpages;
19 
20        $pages = $wpdb->get_results($query);
21        $pages = apply_filters('get_pages', $pages, $r);