#13048 closed defect (bug) (fixed)
WP_Query gets the user ID for author archives twice
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | Query | Version: | |
| Severity: | minor | Keywords: | has-patch |
| Cc: | westi |
Description (last modified by dd32)
Currently WP_Query->get_posts does this:
$q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'");
$q['author'] = get_user_by('slug', $q['author_name']);
Which potentially hits the DB twice for the same info. Looks like an old bit of functionality got left in when the get_user_by call was added. Would be better if it went like this:
$q['author'] = get_user_by('slug', $q['author_name']);
Attachments (1)
Change History (6)
simonwheatley — 3 years ago
comment:1
simonwheatley — 3 years ago
Ugh. Wrong format for the codeblocks in the description, sorry... see the diff. :/
Note: See
TracTickets for help on using
tickets.

A diff to stop WP_Query hitting the DB twice for the author ID on author archives