1

I am trying to figure out what the orderby parameter is for "newest" post author.

http://codex.wordpress.org/Class_Reference/WP_User_Query#Order_.26_Orderby_Parameters

I want to order users by authors who posted the newest posts (post date).

What would be the parameter for that?

Thanks!

1
  • I think the best way to do that would be a custom WP_Query() to get the necessary post IDs you want, then loop through those and get the author for each post ID.
    – cfx
    Mar 19, 2015 at 4:19

1 Answer 1

1

Hi for me fast solution is to use custom query

for eg.

$sql="SELECT
    `wp_users`.`ID`
    , `wp_users`.`user_login`
    , `wp_users`.`user_pass`
    , `wp_users`.`user_nicename`
    , `wp_users`.`user_email`
    , `wp_users`.`user_url`
    , `wp_users`.`user_registered`
    , `wp_users`.`user_activation_key`
    , `wp_users`.`user_status`
    , `wp_users`.`display_name`
    , `wp_posts`.`post_date`
FROM
    `wp_users`
    LEFT JOIN `wp_posts` 
        ON (`wp_users`.`ID` = `wp_posts`.`post_author`)
GROUP BY `wp_users`.`ID`
ORDER BY `wp_posts`.`post_date` DESC;";

global $wpdb;
$results=$wpdb->get_results($sql);
foreach($results as $result) {
    echo $result->ID; //and so on
}
1
  • I think you'll find the OP is referring to WP_User_Query, not WP_Query. See the link in the question
    – shea
    Mar 19, 2015 at 2:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.