I need some code sample, please contribute me some code.

How It Works

Get an answer in three easy steps. Here's how it works...

Ask Your Question

1. Ask Your Question

Enter your WordPress question at the top of this page and click Get An Answer.

Pick Your Priority

2. Pick Your Priority

Tell us how quickly you want your WordPress question answered.

Get An Answer

3. Get An Answer

Connect with your WordPress Expert via online chat or telephone call.

Answer

Customer

I need some code sample, please contribute me some code.

Posted
Albert Shohez
WordPress Expert

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>';
}
?>
Posted
Customer

thank you.

Posted

quoteTestimonialsquote

About ExpertHelp

ExpertHelp is changing the way you connect with service professionals.

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!

More WordPress Questions...

Ask Your WordPress Question & Get An Answer Now!