Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I get all users with atleast one post? I don't think it's possible with get_users function.

share|improve this question
    
This has been answered here for all post types: wordpress.stackexchange.com/questions/31443/… and works well with a post type of 'post'. –  soulseekah Oct 21 '11 at 12:42
add comment

1 Answer

up vote 3 down vote accepted
global $wpdb;
$min_posts = 5; // Make sure it's int, it's not escaped in the query
$author_ids = $wpdb->get_col("SELECT `post_author` FROM
    (SELECT `post_author`, COUNT(*) AS `count` FROM {$wpdb->posts}
        WHERE `post_status`='publish' GROUP BY `post_author`) AS `stats`
    WHERE `count` >= {$min_posts} ORDER BY `count` DESC;");
// Do what you want to $author_ids from here on...

This will return the User IDs of the Authors with 5+ published posts and orders them descending, by post counts.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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