You are here: GeekEstate Blog » Blogging » PHP Code for an Author Sidebar Module for a Multi-Author WordPress Blog

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=”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!

About Drew Meyers

Drew Meyers is the founder and managing editor of Geek Estate Blog. He currently runs ESM Exec Designs, a web design firm specializing in corporate and personal blog design. Travel addict and social entrepreneurship & microfinance advocate.

This entry was posted in Blogging. Bookmark the permalink.
  • http://www.housemeetsowner.com Josh Ferris

    Drew, you're a rockstar in my book! Thanks for generously offering this up to the community.

    • http://www.drewmeyersinsights.com drewmeyers

      Glad I could help!

  • http://twitter.com/DavidGibbons David Gibbons

    I second Josh's Rockstar vote … where's the Like button on this thing?

    • http://www.drewmeyersinsights.com drewmeyers

      I'm guessing one of the RE geeks that reads this blog has a good suggestion for a “like” plugin…

  • http://bayshakti.com Brad Coy

    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!

    • http://www.drewmeyersinsights.com drewmeyers

      No problemo

  • http://www.universityloveconnection.com Eastern Oregon University

    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.

  • http://www.zoombits.de/cases/iphone/gear4-sportarmband-für-iphone-3g-3gs/18354 iphone armband

    Hi,
    WOW,Thats very helpful.Its working well.Thanks for sharing.

  • http://www.ghdrepairsstore.com ghd Hair Straightener

    Can be

  • http://dietapersonala.com/ de slabit

    I 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

2008 - 2012 GEEK ESTATE · ALL RIGHTS RESERVED · A CUSTOM SITE BY