From dbba7a2d8c15e240b4884cbaf6cf439778fd8564 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Sat, 21 Feb 2004 14:10:07 +0000 Subject: [PATCH] New get_posts function, for multiple WP loops. git-svn-id: http://svn.automattic.com/wordpress/trunk@902 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 32bdbcc9a7..9f71f31550 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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; +} + ?> \ No newline at end of file