I need some code sample, please contribute me some code.
Enter your WordPress question at the top of this page and click Get An Answer.
Tell us how quickly you want your WordPress question answered.
Connect with your WordPress Expert via online chat or telephone call.
I need some code sample, please contribute me some code.
I hope the following code snap will help you:(http://wordpress.org/support/topic/how-to-show-top-authors-with-avatar-and-count)
<?php
global $wpdb;
$top_authors = $wpdb->get_results("
SELECT u.ID, count(post_author) as posts FROM {$wpdb->posts} as p
LEFT JOIN {$wpdb->users} as u ON p.post_author = u.ID
WHERE p.post_status = 'publish'
AND p.post_type = 'post'
GROUP by p.post_author
ORDER by posts DESC
LIMIT 0,10
");
if( !empty( $top_authors ) ) {
echo '<ul>';
foreach( $top_authors as $key => $author ) {
echo '
<li>
<a href="' . get_author_posts_url( $author->ID ) . '">' . get_the_author_meta( 'user_nicename' , $author->ID ) . '</a>
(' . $author->posts . ') ' . get_avatar( $author->ID , 4 ) . '
</li>
';
}
echo '</ul>';
}
?>
thank you.
Chris Von Nieda - WordPress Pro and Webmaster
WordPress Expert
Whether you have a quick question while preparing your taxes, troubleshooting a computer problem, or need to hire an attorney, ExpertHelp is the most convenient and affordable way to connect with the right service professional to get the job done.
ExpertHelp has been in business since 2011, is an A+ Rated Better Business Bureau accredited member, and offers a 100% satisfaction guarantee on every question you ask!