Support for categories - http://mosquito.wordpress.org/view.php?id=52
git-svn-id: https://develop.svn.wordpress.org/trunk@2311 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3c85ef13dd
commit
3b25d5706b
|
@ -974,14 +974,19 @@ function get_posts($args) {
|
||||||
parse_str($args, $r);
|
parse_str($args, $r);
|
||||||
if (!isset($r['numberposts'])) $r['numberposts'] = 5;
|
if (!isset($r['numberposts'])) $r['numberposts'] = 5;
|
||||||
if (!isset($r['offset'])) $r['offset'] = 0;
|
if (!isset($r['offset'])) $r['offset'] = 0;
|
||||||
// The following not implemented yet
|
|
||||||
if (!isset($r['category'])) $r['category'] = '';
|
if (!isset($r['category'])) $r['category'] = '';
|
||||||
|
// The following not implemented yet
|
||||||
if (!isset($r['orderby'])) $r['orderby'] = '';
|
if (!isset($r['orderby'])) $r['orderby'] = '';
|
||||||
if (!isset($r['order'])) $r['order'] = '';
|
if (!isset($r['order'])) $r['order'] = '';
|
||||||
|
|
||||||
$now = current_time('mysql');
|
$now = current_time('mysql');
|
||||||
|
|
||||||
$posts = $wpdb->get_results("SELECT DISTINCT * FROM $wpdb->posts WHERE post_date <= '$now' AND (post_status = 'publish') GROUP BY $wpdb->posts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts']);
|
$posts = $wpdb->get_results(
|
||||||
|
"SELECT DISTINCT * FROM $wpdb->posts " .
|
||||||
|
( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
|
||||||
|
" WHERE post_date <= '$now' AND (post_status = 'publish') ".
|
||||||
|
( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
|
||||||
|
" GROUP BY $wpdb->posts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
|
||||||
|
|
||||||
update_post_caches($posts);
|
update_post_caches($posts);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue