Make WordPress Core


Ignore:
Timestamp:
02/21/2004 02:10:07 PM (21 years ago)
Author:
saxmatt
Message:

New get_posts function, for multiple WP loops.

File:
1 edited

Legend:

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

    r892 r902  
    14701470}
    14711471
     1472function get_posts($args) {
     1473    global $wpdb, $tableposts;
     1474    parse_str($args, $r);
     1475    if (!isset($r['numberposts'])) $r['numberposts'] = 5;
     1476    if (!isset($r['offset'])) $r['offset'] = 0;
     1477    // The following not implemented yet
     1478    if (!isset($r['category'])) $r['category'] = '';
     1479    if (!isset($r['orderby'])) $r['orderby'] = '';
     1480    if (!isset($r['order'])) $r['order'] = '';
     1481
     1482    $now = current_time('mysql');
     1483
     1484    $posts = $wpdb->get_results("SELECT DISTINCT * FROM $tableposts WHERE post_date <= '$now' AND (post_status = 'publish') GROUP BY $tableposts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts']);
     1485   
     1486    return $posts;
     1487}
     1488
    14721489?>
Note: See TracChangeset for help on using the changeset viewer.