WordPress.org

Make WordPress Core

Ticket #4531: 4531-number-offset-get_pages.diff

File 4531-number-offset-get_pages.diff, 917 bytes (added by Speedboxer, 9 years ago)

Updated patch

  • post.php

     
    21412141                'sort_column' => 'post_title', 'hierarchical' => 1,
    21422142                'exclude' => '', 'include' => '',
    21432143                'meta_key' => '', 'meta_value' => '',
    2144                 'authors' => '', 'parent' => -1, 'exclude_tree' => ''
     2144                'authors' => '', 'parent' => -1, 'exclude_tree' => '',
     2145                'number' => '', offset => '0'
    21452146        );
    21462147
    21472148        $r = wp_parse_args( $args, $defaults );
    21482149        extract( $r, EXTR_SKIP );
     2150        $number = (int) $number;
     2151        $offset = (int) $offset;
    21492152
    21502153        $cache = array();
    21512154        $key = md5( serialize( compact(array_keys($defaults)) ) );
     
    22432246        $query .= $author_query;
    22442247        $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
    22452248
     2249        if ( !empty($number) )
     2250                $query .= ' LIMIT ' . $offset . ',' . $number;
     2251
    22462252        $pages = $wpdb->get_results($query);
    22472253
    22482254        if ( empty($pages) ) {