Show authors in category (Wordpress)

jdunhin

Active member
Registered
Joined
Feb 27, 2013
Messages
72
Points
0
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:
<?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>';
}
}
?>
 
Last edited by a moderator:

Jack London

Well-known member
Joined
Jul 9, 2012
Messages
158
Points
18
Useful code, Jdunhin. I am using wordpress flatform for my blog. but why don't you use this code
Code:
<?php the_author(); ?>
to show author name in wordpress ? . It's shorter than your code you showed
 

jdunhin

Active member
Registered
Joined
Feb 27, 2013
Messages
72
Points
0
I struggled with that to show just users of a certain category. I was also near my deadline for the website and need results before the end of the day :)
 

Jack London

Well-known member
Joined
Jul 9, 2012
Messages
158
Points
18
with wordpress can you make references from internet or wordpress community.
on your signature, is Webbroker your site ? and did you do it on wordpress ?
 

Dmoz

Member
Registered
Joined
Jul 7, 2012
Messages
46
Points
0
hi jdunhin, do you show your code in action ( on website ). I think it's a custom code and maybe helpful for me.
 

jdunhin

Active member
Registered
Joined
Feb 27, 2013
Messages
72
Points
0
Yes WebBroker is my online business. Yes it is on Wordpress. I use wordpress for everything and develop more functions if I need more.

Yes, I think I'm allowed to put my link on :)
 

jdunhin

Active member
Registered
Joined
Feb 27, 2013
Messages
72
Points
0
I usually buy themes or use Hybrid basic and make a child theme from the theme. Then I customize the !@#$ out of it :). Like this auction theme I bought it for the auction function.

I'm one of the lucky people because my work is to build themes and develop on Wordpress for a big company in South Africa. So it is very fun!

Thank you for you kind words!!
 

jdunhin

Active member
Registered
Joined
Feb 27, 2013
Messages
72
Points
0
Dmoz,

I used this code on your intranet for all your different departments, they basically have there own "rooms" if I can call it that :)
 
Last edited:
Older Threads
Newer Threads
Replies
0
Views
1,790
Replies
0
Views
2,219
Replies
0
Views
2,267
Replies
3
Views
2,580

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top