WordPress.org

Make WordPress Core

Ticket #13048: do not get author ID twice.diff

File do not get author ID twice.diff, 644 bytes (added by simonwheatley, 5 years ago)

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

  • Users/simon/Projects/WordPress-Bleeding/site/wp-includes/query.php

     
    20802080                                } 
    20812081                        } 
    20822082                        $q['author_name'] = sanitize_title($q['author_name']); 
    2083                         $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'"); 
    20842083                        $q['author'] = get_user_by('slug', $q['author_name']); 
    20852084                        if ( $q['author'] ) 
    20862085                                $q['author'] = $q['author']->ID;