PHP Code for an Author Sidebar Module for a Multi-Author WordPress Blog
December 8, 2009
By: Drew Meyers
Author's Website: http://youreachmedia.com
I just got a DM from fellow Geek Estate contributor Josh Ferris and thought it best to just answer the question publicly rather than privately given that it’s a question I myself had awhile back.
Question: “what plug-in did you use for the author sidebar [module] on GEB? I’d like to have something similar for a multi-author blog I’m working on.”
Answer: It’s not a plug-in, but some custom PHP code that originated with Cory Miller and was iterated upon by one of Zillow’s developers (@henryrose) as part of developing the theme for Mortgages Unzipped. Since I actually spent a fair amount of time searching for sample code or a plug-in to accomplish this and came away with nothing, I thought I might as well post the full code here to save others time in the future. Here’s the code:
<h2>Recent Contributors</h2>
<div>
<?php$limit = ’10′;
$query = “select post_author as ID, max(post_date)
from $wpdb->posts
where post_type = ‘post’ and post_status = ‘publish’
group by post_author
order by 2 desc
limit $limit;”;
$usersinfo = $wpdb->get_results($query);
foreach($usersinfo as $userinfo){
$user = get_userdata($userinfo->ID);
$user->postcount = $userinfo->postcount;
?><div>
<?php if( $user->aim != ”){ ?>
<img width=”57″ alt=”<?php echo $user->aim; ?>” src=”<?PHP echo $user->aim; ?>” />
<? }else{
?>
<img width=”57″ alt=”no image” src=”http://www.geekestateblog.com/images/blankphoto.jpg” />
<?php } ?>
<ul>
<li><strong><?php echo $user->first_name; ?> <?php echo $user->last_name; ?> </strong></li><?php if ($user->yim != ”){ ?>
<li><a href=”<?PHP echo $user->user_url; ?>”><?PHP echo $user->yim; ?></a></li>
<? } ?><?php if ($user->jabber != ”){ ?>
<li><a href=”<?PHP echo $user->jabber ?>”>Blog</a></li>
<? } ?><li> <a rel=”nofollow” href=”http://www.geekestateblog.com/author/<?PHP echo $user->user_login ?>”>View Posts</a> | <a rel=”nofollow” href=”<?php echo get_author_feed_link($user->ID); ?>”>RSS</a></li>
</ul>
</div>
<?php
}
?>
</div>
As you may or may not know, I’m a huge advocate of guest blogging and multi-author blogs (I also run myKRO.org), so very much understand the importance of giving authors as much recognition and exposure as possible for their time. Of course, if there is a great plug-in that offers similar functionality, please leave a link to it in the comments!
- Stumble it!
- Categories: Blogging
Enjoy this post? Subscribe to the Geek Estate Blog feed or get updates via e-mail
Comments
View Comments





Josh Ferris on December 8, 2009 11:51 am
Drew, you're a rockstar in my book! Thanks for generously offering this up to the community.
drewmeyers on December 8, 2009 11:03 pm
Glad I could help!
David Gibbons on December 8, 2009 11:44 pm
I second Josh's Rockstar vote … where's the Like button on this thing?
drewmeyers on December 8, 2009 11:53 pm
I'm guessing one of the RE geeks that reads this blog has a good suggestion for a “like” plugin…
Brad Coy on December 9, 2009 2:37 am
awesome. this is just what I was looking for. my wife and I started a new multi-author blog and this was on the wish list. Thanks Drew!
drewmeyers on December 9, 2009 10:44 am
No problemo
Eastern Oregon University on December 11, 2009 9:29 am
We have a few college students online from College of University of New Mexico and we love your blog postings, so well add your rss or news feed for them, Thanks and please post us and leave a comment back and well link to you. Thanks Jen , Blog Manager University of New Mexico.
iphone armband on December 20, 2009 11:29 pm
Hi,
WOW,Thats very helpful.Its working well.Thanks for sharing.