$data = $wpdb->get->results("SELECT * FROM (SELECT wp_users.ID, display_name, user_login, user_nicename, count(wp_posts.ID) AS n, substring_index(display_name,\' \',-1) AS lastname FROM wp_users JOIN wp_posts ON wp_posts.post_author = wp_users.ID GROUP BY wp_posts.post_author ORDER BY n DESC LIMIT 10 ) AS SortedByCount ORDER BY lastname");
现在,您拥有了$数据数组中的所有内容。按帖子数量正确排序,然后按姓氏正确排序(自动计算)
这是一个简单的问题
选择*FROM(选择wp\\u users.ID、display\\u name、user\\u login、user\\u nicename、count(wp\\u posts.ID)作为n,substring\\u index(display\\u name,,-1)作为来自wp\\u的lastname。用户在wp\\u posts上加入wp\\u posts。post\\u author=wp\\u用户。ID按wp\\U帖子分组。post\\u author ORDER BY n DESC LIMIT 10)作为SortedByCount ORDER BY lastname
最好的