在WordPress中,我需要获取创建帖子的作者的Author图像。我试图以这种方式获取个人资料图片,但没有用。
这是我为获取其他author_meta_details而编写的代码。
<div class="row">
<div class="avatar col-md-3">
<picture class="avatar-circle">
<?php if($avatar = get_avatar(get_the_author_meta('ID')) !== FALSE): ?>
<img src="<?php echo $avatar; ?>" alt="">
<?php else: ?>
<img src="/wp-content/themes/lymited-child/images/avatar-image.png">
<?php endif; ?>
</picture>
</div>
<div class="author-details col-md-9">
<div class="author-name"><strong><?php echo get_the_author_meta('first_name'); ?></strong> - <?php echo get_the_author_meta('nickname'); ?>
</div>
<div class="author-summery"><?php echo get_the_author_meta('description'); ?>
</div>
</div>
</div>
答案 0 :(得分:0)
df1['aaa'] = np.vstack((np.nan, arr1[:,0]))
返回get_avatar()
元素,因此您无需再次将其包装到<img>
另外,您需要将img
括在括号中,因为$avatar = ...
的优先级低于=
尝试替换
!==
与此
<?php if ( $avatar = get_avatar(get_the_author_meta('ID')) !== FALSE): ?>
<img src="<?php echo $avatar; ?>" alt="">
答案 1 :(得分:0)
尝试
<?php
$get_author_id = get_the_author_meta('ID');
$get_author_gravatar = get_avatar_url($get_author_id, array('size' => 450));
if(has_post_thumbnail()){
the_post_thumbnail();
} else {
echo '<img src="'.$get_author_gravatar.'" alt="'.get_the_title().'" />';
}
?>
或根据情况删除此内容并尝试
echo get_avatar( get_the_author_meta('ID') );