New get_posts function, for multiple WP loops.

git-svn-id: https://develop.svn.wordpress.org/trunk@902 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2004-02-21 14:10:07 +00:00
parent f69f39dd6e
commit c3be4eeb68
1 changed files with 17 additions and 0 deletions

View File

@ -1469,4 +1469,21 @@ function remove_slashes($string) {
return stripslashes(stripslashes($string));
}
function get_posts($args) {
global $wpdb, $tableposts;
parse_str($args, $r);
if (!isset($r['numberposts'])) $r['numberposts'] = 5;
if (!isset($r['offset'])) $r['offset'] = 0;
// The following not implemented yet
if (!isset($r['category'])) $r['category'] = '';
if (!isset($r['orderby'])) $r['orderby'] = '';
if (!isset($r['order'])) $r['order'] = '';
$now = current_time('mysql');
$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']);
return $posts;
}
?>