Show authors in category (Wordpress)

1 replies
  • WEB DESIGN
  • |
I have struggle the whole morning with this code. This is to show authors from a certain category. Feel free to make it work for you, but this works for me....

<?php
$catauthors = array();
$citycat=8;
$allposts=get_posts("cat=$citycat&showposts=-1");
if ($allposts) {
foreach($allposts as $authorpost) {
$catauthors[$authorpost->post_author]+=1;
}
arsort($catauthors); //sort array in reverse order by number of posts
foreach($catauthors as $key => $author_post_count) {
$curuser = get_userdata($key);
$author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename);
echo '<p><a href="' . $author_post_url . '" title="' . sprintf( __( "Posts by %s" ), $curuser->user_nicename ) . '" ' . '>' . $curuser->user_nicename .'</a></p>';
}
}
?>
#authors #category #show #wordpress
  • Profile picture of the author MattSabia
    I've never seen something like this. Thanks for sharing.
    Signature
    How I Built My First $3000/Month Cashflow Business With A Facebook Group - Watch My Webinar
    {{ DiscussionBoard.errors[6598905].message }}

Trending Topics