Custom post type support for get_users(‘orderby=post_count’);

you can try to replace the where clause of the query by hooking to pre_user_query. Something like:

function user_query_count_post_type($args){
    $args->query_from = str_replace("post_type = post AND", "post_type IN ('post','cpt') AND ", $args->query_from);
}

Usage ex:

add_action('pre_user_query','user_query_count_post_type');
$users = get_users('orderby=post_count');
remove_action('pre_user_query','user_query_count_post_type');

Leave a Comment