Skip to content

Instantly share code, notes, and snippets.

@utkarshkukreti
Forked from kingsidharth/Author List
Created March 24, 2012 12:11
Show Gist options
  • Save utkarshkukreti/2181653 to your computer and use it in GitHub Desktop.
Save utkarshkukreti/2181653 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);
if($user->nicename == "first_nicename" || $user->nicename == "second_to_exclude") continue;
$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