0

我将著名的用户照片插件用于我的 Wordpress 网站。我想在循环外显示当前登录用户的头像。这怎么可能?

我用来在循环内显示作者头像的当前代码是:

<?php userphoto_the_author_thumbnail('', '', array(width => '40', height => '40')); ?>

谷歌没有给我太多继续。一个人提到了这段代码:

global $authordata;
$authordata=get_userdata(get_query_var( 'author' ));
userphoto_the_author_thumbnail();

但它没有用。解决办法是什么?

4

3 回答 3

2

试试下面的代码。

它将选择当前登录用户的电子邮件,然后显示头像。

<?php
    wp_get_current_user();
    $current_user_email = $current_user->user_email;
?>
<?php echo get_avatar( '$current_user_email', 40 ); ?>
于 2012-09-10T13:09:54.993 回答
0

请尝试这两个之一。

userphoto($user, $before = '', $after = '', $attributes = array(), $default_src = '')

或者

userphoto_thumbnail($user, $before = '', $after = '', $attributes = array(), $default_src = '')

两个功能的工作方式相同userphoto_the_author_thumbnail

谢谢

于 2012-09-10T13:09:33.073 回答
0

使用 userphoto_thumbnail() 并明确传递用户 ID。

用法:

userphoto_thumbnail($user, $before = '', $after = '', $attributes = array(), $default_src = '')
于 2012-09-10T13:06:30.880 回答