Allow ordering by comment_count. fixes #11037

git-svn-id: http://svn.automattic.com/wordpress/trunk@12127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2009-10-29 18:02:55 +00:00
parent 6ecb855d33
commit dd4b5f01c0
1 changed files with 3 additions and 1 deletions

View File

@ -2029,7 +2029,7 @@ class WP_Query {
$q['orderby'] = ''; $q['orderby'] = '';
} else { } else {
// Used to filter values // 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']) ) { if ( !empty($q['meta_key']) ) {
$allowed_keys[] = $q['meta_key']; $allowed_keys[] = $q['meta_key'];
$allowed_keys[] = 'meta_value'; $allowed_keys[] = 'meta_value';
@ -2056,6 +2056,8 @@ class WP_Query {
case 'meta_value': case 'meta_value':
$orderby = "$wpdb->postmeta.meta_value"; $orderby = "$wpdb->postmeta.meta_value";
break; break;
case 'comment_count':
$orderby = "$wpdb->posts.comment_count";
default: default:
$orderby = "$wpdb->posts.post_" . $orderby; $orderby = "$wpdb->posts.post_" . $orderby;
} }