Get authors for post category

View: New views
3 Messages — Rating Filter:   Alert me  

Get authors for post category

by SoJ Web :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

Does anyone know of an easy way to get all the authors for posts in a  
certain category? I'd like to have an author list that only includes  
authors who've posted to a particular category, and I'd like to avoid  
writing a custom query, if possible. Thanks.


-Jeff

_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: Get authors for post category

by scribu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There is no "easy" way:

$post_ids = implode(',', get_objects_in_term($term_id, 'category'));

$authors = $wpdb->get_results("
SELECT DISTINCT *
FROM $wpdb->users u
JOIN $wpdb->posts p ON (p.author_id = u.ID)
WHERE p.ID IN ('$post_ids')
");


--
http://scribu.net
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: Get authors for post category

by SoJ Web :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That's what I was afraid of :-). Thanks.


-Jeff

On Nov 5, 2009, at 10:16 AM, scribu wrote:

> There is no "easy" way:
>
> $post_ids = implode(',', get_objects_in_term($term_id, 'category'));
>
> $authors = $wpdb->get_results("
> SELECT DISTINCT *
> FROM $wpdb->users u
> JOIN $wpdb->posts p ON (p.author_id = u.ID)
> WHERE p.ID IN ('$post_ids')
> ");
>
>
> --
> http://scribu.net
> _______________________________________________
> wp-hackers mailing list
> wp-hackers@...
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers