Show authors in category (Wordpress)

jdunhin

New member
Joined
Feb 27, 2013
Messages
93
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

New member
Joined
Jul 9, 2012
Messages
386
Points
0
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

New member
Joined
Feb 27, 2013
Messages
93
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

New member
Joined
Jul 9, 2012
Messages
386
Points
0
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

New member
Joined
Jul 7, 2012
Messages
121
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

New member
Joined
Feb 27, 2013
Messages
93
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

New member
Joined
Feb 27, 2013
Messages
93
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

New member
Joined
Feb 27, 2013
Messages
93
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
Replies
1
Views
2,460
Replies
1
Views
2,413
Replies
1
Views
2,276
Replies
5
Views
2,458
Replies
3
Views
2,335
Newer threads
Replies
0
Views
2,004
Replies
0
Views
2,345
Replies
0
Views
2,546
Replies
6
Views
4,464
Replies
6
Views
3,731
Latest threads
Replies
0
Views
590
Replies
2
Views
789
Similar threads

Referral contests

Referral link for :

Sponsors

Popular tags

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