[wp-hackers] wp_list_authors and DB queries
DD32
wordpress at dd32.id.au
Thu Nov 22 03:22:38 GMT 2007
Couldnt you just add
ORDER BY display_name
to the SQL Query?
On Thu, 22 Nov 2007 14:19:59 +1100, Bob <wp-hackers at nj-arp.org> wrote:
> OK, I threw in a sort of the array. Here's the user-defined function to do
> the comparison:
>
> function wp_widget_authors_cmp($a, $b) {
> $al = strtolower($a->display_name);
> $bl = strtolower($b->display_name);
> if ($al == $bl) {
> return 0;
> }
> return ($al < $bl) ? -1 : 1;
> }
>
>
> And the call to usort just before the foreach ($authors as $author):
>
> usort($authors, "wp_widget_authors_cmp");
>
>
>
> ----- Original Message -----
> From: "Bob" <wp-hackers at nj-arp.org>
> To: <wp-hackers at lists.automattic.com>
> Sent: Wednesday, November 21, 2007 9:16 PM
> Subject: Re: [wp-hackers] wp_list_authors and DB queries
>
>
>> Wow, that's great! Thanks! But how can I change the author's sort order?
>> It seems to be ordered by ID. Can it be sorted by display_name?
>>
>> Bob
>>
>>
>> ----- Original Message -----
>> From: "Alexander Concha" <alex at buayacorp.com>
>> To: <wp-hackers at lists.automattic.com>
>> Sent: Wednesday, November 21, 2007 8:14 PM
>> Subject: Re: [wp-hackers] wp_list_authors and DB queries
>>
>>
>>> Bob escribió:
>>>> I wrote my own version of the widget/plugin. I hardcoded an array with
>>>> the
>>>> author IDs to display, then called get_userdata() and get_usernumposts()
>>>> in
>>>> a foreach loop. That cut the number of queries to 44, still 21 higher
>>>> than
>>>> normal, and the time to 0.020 seconds more than normal.
>>>>
>>>> That's an improvement over the generic plugin, but I was hoping for
>>>> better.
>>>> I'd appreciate it if anyone has any more suggestions.
>>>
>>> Look at the changes I made [1], it only uses one query (two if
>>> "show_fullname" is enabled) to do the same thing, but probably the
>>> plugin will fail (if database schema changes) in future versions of WP.
>>>
>>> [1] http://wordpress.pastebin.com/m6d2e537
>>>
>>> Regards
>>> --
>>> Alexander Concha
>>> http://www.buayacorp.com/
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list