开发者

List authors with gravatar and other data in wordpress?

开发者 https://www.devze.com 2023-01-13 09:41 出处:网络
How do I list authors with their gravatar, first namne last name and nicknam开发者_如何学运维e in wordpress?This is how I did it!

How do I list authors with their gravatar, first namne last name and nicknam开发者_如何学运维e in wordpress?


This is how I did it!

            <?php
             // Displays user name and email from users with at least one post
            $blogusers = get_users_of_blog();
            if ($blogusers) {
              foreach ($blogusers as $bloguser) {
                $args = array(
                'author' => $bloguser->user_id,
                  'showposts' => 1,
                  'caller_get_posts' => 1
                );
                $my_query = new WP_Query($args);
                if( $my_query->have_posts() ) {
                  $user = get_userdata($bloguser->user_id);
                  echo "<img src='http://www.gravatar.com/avatar/" . md5( strtolower( trim( " $user->user_email " ) ) )."?s=125' /><li>".$user->user_firstname."</li><li>".$user->user_lastname."</li>";
                }
              }
            }

?>

0

精彩评论

暂无评论...
验证码 换一张
取 消