I’m using Barcelona theme and I need to get authors who have posted in certain category.
In my author.php template I have:
$barcelona_authors = get_users( array(
'fields' => 'ID',
'who' => 'authors',
'order' => 'DESC',
'orderby'=> 'post_count'
) );
<?php
foreach ( $barcelona_authors as $barcelona_author_id ) {
barcelona_author_box( $barcelona_author_id, false );
}
?>
How to get authors who have posted to category ID 59?
For example I tried with:
$barcelona_authors = get_posts('category=59');
But I’m getting error. Any help?
ERROR:
Notice: Object of class WP_Post could not be converted to int in
/home/wp-includes/author-template.php on line 296
Your
get_posts( 'category=59' )
code should work. I have tested the following on one of my test wordpress installation and it works (with a different category ID of course). If you get an error during theget_posts
call you need to show us the error.This was the solution for Barcelona theme: