[wp-trac] [WordPress Trac] #17123: WP_User_Query ordered by post_count doesn't work if prefix is not wp_
WordPress Trac
wp-trac at lists.automattic.com
Wed Apr 13 14:06:12 UTC 2011
#17123: WP_User_Query ordered by post_count doesn't work if prefix is not wp_
--------------------------+-----------------------------
Reporter: ziofix | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version: 3.1
Severity: major | Keywords: has-patch
--------------------------+-----------------------------
If you try this:
{{{
#!php
$q = WP_User_Query( array( 'orderby' => 'post_count' ) );
}}}
it won't work if your table prefix is different than 'wp_', because it's
hard coded in wp-includes/user.php line 441 :
{{{
#!php
$this->query_from .= " LEFT OUTER JOIN (
SELECT post_author, COUNT(*) as post_count
FROM wp_posts
$where
GROUP BY post_author
) p ON ({$wpdb->users}.ID = p.post_author)
";
}}}
it should be replaced by:
{{{
#!php
$this->query_from .= " LEFT OUTER JOIN (
SELECT post_author, COUNT(*) as post_count
FROM $wpdb->posts
$where
GROUP BY post_author
) p ON ({$wpdb->users}.ID = p.post_author)
";
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17123>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list