2 回答

TA貢獻1773條經驗 獲得超3個贊
嘗試這個
<?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') );

TA貢獻1784條經驗 獲得超9個贊
get_avatar()返回<img>元素,因此您無需再次將其包裝img起來也需要包裝$avatar = ...到括號中,因為=優先級低于!==
嘗試更換這個
<?php if ( $avatar = get_avatar(get_the_author_meta('ID')) !== FALSE): ?>
<img src="<?php echo $avatar; ?>" alt="">
有了這個
<?php if ( ( $avatar = get_avatar(get_the_author_meta('ID')) ) !== FALSE): ?>
<?php echo $avatar; ?>
- 2 回答
- 0 關注
- 109 瀏覽
添加回答
舉報