#17123 closed defect (bug) (fixed)
WP_User_Query ordered by post_count doesn't work if prefix is not wp_
| Reported by: | ziofix | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1.2 |
| Component: | Users | Version: | 3.1 |
| Severity: | major | Keywords: | has-patch |
| Cc: | Focuses: |
Description
If you try this:
$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 :
$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:
$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) ";
Attachments (1)
Change History (6)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
introduced in [15491]