Php Can';无法在帖子中获得当前作者的头像

Php Can';无法在帖子中获得当前作者的头像,php,wordpress,avatar,author,Php,Wordpress,Avatar,Author,出于某种原因,get_avatar($user_email,125)不起作用。我不明白为什么。这是我在single.php中的代码: <?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); $user_email = $curauth->user_email; ?> <div

出于某种原因,
get_avatar($user_email,125)不起作用。我不明白为什么。这是我在
single.php
中的代码:

<?php
    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    $user_email = $curauth->user_email;
?>

  <div class="author-box clearfix">
      <img class="author" src="<?php echo get_avatar($user_email, 125); ?> " width="125" height="125" alt="<?php echo the_author_meta( 'display_name' , $author_id ); ?>" />
        <h4 class="title"><?php echo get_the_author(); ?></h4>
        <p class="title"><?php the_author_meta( 'title' ); ?></p>
        <p class="info"><strong>M: </strong><?php the_author_meta( 'user_email' ); ?></p>
        <p class="info"><strong>W: </strong><a href="<?php the_author_meta( 'user_url' ); ?>"><?php the_author_meta( 'user_url' ); ?></a></p>
  </div>

“width=“125”height=“125”alt=”“/>

M:

W:

从文档中,它返回整个图像元素字符串

检索用户、电子邮件地址、MD5哈希、评论或帖子的化身标签

您使用它的方式是,您需要图像url,所以请使用

Return:(false | string)我们找到的化身的URL,如果我们找不到化身,则返回false

学习创建自己的作者框

echo get_avatar( get_the_author_meta('email'), '90' );