From 19416faeacc85c4bdefa79392d0d34b250a20c7c Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 29 Oct 2009 18:02:55 +0000 Subject: [PATCH] Allow ordering by comment_count. fixes #11037 git-svn-id: https://develop.svn.wordpress.org/trunk@12127 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index f09c9fe6c8..4a39dde583 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2029,7 +2029,7 @@ class WP_Query { $q['orderby'] = ''; } else { // Used to filter values - $allowed_keys = array('author', 'date', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand'); + $allowed_keys = array('author', 'date', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand', 'comment_count'); if ( !empty($q['meta_key']) ) { $allowed_keys[] = $q['meta_key']; $allowed_keys[] = 'meta_value'; @@ -2056,6 +2056,8 @@ class WP_Query { case 'meta_value': $orderby = "$wpdb->postmeta.meta_value"; break; + case 'comment_count': + $orderby = "$wpdb->posts.comment_count"; default: $orderby = "$wpdb->posts.post_" . $orderby; }