summaryrefslogtreecommitdiffstats
path: root/wp-includes/category.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-07-12 15:10:29 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-07-12 15:10:29 +0000
commit9b546c68fc36523578d54fec5207a10eb3fc8145 (patch)
tree75f892373ee944df9fe853ee07ee05ae07836143 /wp-includes/category.php
parent4baf29175c471216ae4aa709fbbffc7db569d788 (diff)
downloadwordpress-mu-9b546c68fc36523578d54fec5207a10eb3fc8145.tar.gz
wordpress-mu-9b546c68fc36523578d54fec5207a10eb3fc8145.tar.xz
wordpress-mu-9b546c68fc36523578d54fec5207a10eb3fc8145.zip
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@663 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/category.php')
-rw-r--r--wp-includes/category.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 8c73e6c..30392a7 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -20,9 +20,14 @@ function &get_categories($args = '') {
parse_str($args, $r);
$defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
- 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, $exclude => '', $include => '');
+ 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, $exclude => '', $include => '',
+ 'number' => '');
$r = array_merge($defaults, $r);
- $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields
+ if ( 'count' == $r['orderby'] )
+ $r['orderby'] = 'category_count';
+ else
+ $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields
+ $r['number'] = (int) $r['number'];
extract($r);
$where = 'cat_ID > 0';
@@ -70,7 +75,12 @@ function &get_categories($args = '') {
$having = 'HAVING category_count > 0';
}
- $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where $having ORDER BY $orderby $order");
+ if ( !empty($number) )
+ $number = 'LIMIT ' . $number;
+ else
+ $number = '';
+
+ $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where $having ORDER BY $orderby $order $number");
if ( empty($categories) )
return array();