Skip to content

Instantly share code, notes, and snippets.

@kingsidharth
Created March 24, 2012 11:59
Show Gist options
  • Save kingsidharth/2181564 to your computer and use it in GitHub Desktop.
Save kingsidharth/2181564 to your computer and use it in GitHub Desktop.
function authors_orderBy($data, $field){
$code = "if (\$a['$field'] == \$b['$field']) {return 0;} return (\$a['$field'] < \$b['$field']) ? 1 : -1;";
usort($data, create_function('$a,$b', $code));
return $data;
}
function author_list(){
if(is_page('the-team')) {
$blogusers = get_users_of_blog();
if ($blogusers) {
$au = array();
foreach ($blogusers as $bloguser) {
$user = get_userdata($bloguser->user_id);
$post_count = count_user_posts($user->ID);
$au[] = array('user_id' => $user->ID , 'nicename' => $user->user_nicename, 'display_name' => $user->display_name, 'email' => $user->user_email ,'post_count' => $post_count, 'bio' => $user-> description);
}
//Sort array
//$au = array_slice($au, 0, 5);
$au = authors_orderBy($au, 'post_count');
//then loop through the authors
foreach ($au as $aut){
if ($aut['post_count'] > 0) {
echo '<li>';
echo '<a href="'.get_bloginfo('url').'/author/' . $aut['nicename'] . '">'.get_avatar($aut['email'], '66').'</a>';
echo '<a href="'.get_bloginfo('url').'/author/' . $aut['nicename'] . '">'.$aut['display_name'] . /* ' ('.$aut['post_count'].')*/ '</a>';
echo '<p class="bio">'.$aut['bio'].'</p>';
echo '</li>';
}
}
}
}}
add_action('thesis_hook_before_post','author_list');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment