1
我正在開發一個自定義WordPress主題,並根據設計要求,我必須在圖像的背景中設置作者Gravatar。如何在Wordpress中將Gravatar設置爲背景圖片?
我已經嘗試使用get_avatar_url()
與wp_get_attachment_image_src
如下,但未能實現:
PHP內嵌代碼:
<?php $thumb = wp_get_attachment_image_src(get_avatar_url($post->ID), '80'); ?>
<div class="author" style="background-image: url('<?php echo $thumb[0]; ?>')"></div>
CSS:
.author {
width:120px;
height:120px;
background: no-repeat center;
}
如何做到這一點?