PHP Code for an Author Sidebar Module for a Multi-Author WordPress Blog
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=”https://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=”https://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!
Josh Ferris
Posted at 11:51h, 08 DecemberDrew, you're a rockstar in my book! Thanks for generously offering this up to the community.
drewmeyers
Posted at 23:03h, 08 DecemberGlad I could help!
David Gibbons
Posted at 23:44h, 08 DecemberI second Josh's Rockstar vote … where's the Like button on this thing?
drewmeyers
Posted at 23:53h, 08 DecemberI'm guessing one of the RE geeks that reads this blog has a good suggestion for a “like” plugin…
Brad Coy
Posted at 02:37h, 09 Decemberawesome. 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
Posted at 10:44h, 09 DecemberNo problemo
Eastern Oregon University
Posted at 09:29h, 11 DecemberWe 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
Posted at 23:29h, 20 DecemberHi,
WOW,Thats very helpful.Its working well.Thanks for sharing.
ghd Hair Straightener
Posted at 09:38h, 01 JanuaryCan be
de slabit
Posted at 23:17h, 03 JanuaryI have been searching the Internet for this info and just wanted to say thanks to you for this post. By the way, just off topic, how can i find a version of this theme? – Thanks
Hyper Local Blogs - Getting Back to the Basics of Early Real Estate Blogging - GeekEstate Blog
Posted at 12:43h, 30 May[…] Give everyone ad space for their business, or simply a prominent about the author module with their photo with each post and a recent authors module on the sidebar (here’s some code for you). […]