Make WordPress Core


Ignore:
Timestamp:
04/09/2005 05:30:57 PM (21 years ago)
Author:
ryan
Message:

Implement order and orderby for get_posts(). http://mosquito.wordpress.org/view.php?id=1161 Props: RummandDan

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r2524 r2525  
    10531053        if (!isset($r['offset'])) $r['offset'] = 0;
    10541054        if (!isset($r['category'])) $r['category'] = '';
    1055         // The following not implemented yet
    1056         if (!isset($r['orderby'])) $r['orderby'] = '';
    1057         if (!isset($r['order'])) $r['order'] = '';
     1055        if (!isset($r['orderby'])) $r['orderby'] = 'post_date';
     1056        if (!isset($r['order'])) $r['order'] = 'DESC';
    10581057
    10591058        $now = current_time('mysql');
     
    10641063                " WHERE post_date <= '$now' AND (post_status = 'publish') ".
    10651064                ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
    1066                 " GROUP BY $wpdb->posts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
    1067 
     1065                " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
     1066       
    10681067    update_post_caches($posts);
    10691068       
Note: See TracChangeset for help on using the changeset viewer.