1 | Index: functions.php |
---|
2 | =================================================================== |
---|
3 | --- functions.php (revision 2474) |
---|
4 | +++ functions.php (working copy) |
---|
5 | @@ -1031,9 +1031,8 @@ |
---|
6 | if (!isset($r['numberposts'])) $r['numberposts'] = 5; |
---|
7 | if (!isset($r['offset'])) $r['offset'] = 0; |
---|
8 | if (!isset($r['category'])) $r['category'] = ''; |
---|
9 | - // The following not implemented yet |
---|
10 | - if (!isset($r['orderby'])) $r['orderby'] = ''; |
---|
11 | - if (!isset($r['order'])) $r['order'] = ''; |
---|
12 | + if (!isset($r['orderby'])) $r['orderby'] = 'post_date'; |
---|
13 | + if (!isset($r['order'])) $r['order'] = 'DESC'; |
---|
14 | |
---|
15 | $now = current_time('mysql'); |
---|
16 | |
---|
17 | @@ -1042,8 +1041,8 @@ |
---|
18 | ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) . |
---|
19 | " WHERE post_date <= '$now' AND (post_status = 'publish') ". |
---|
20 | ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) . |
---|
21 | - " GROUP BY $wpdb->posts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts'] ); |
---|
22 | - |
---|
23 | + " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] ); |
---|
24 | + |
---|
25 | update_post_caches($posts); |
---|
26 | |
---|
27 | return $posts; |
---|