Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

comment template - gravatar image as background image WordPress

  • SOLVED

Trying to make a custom comment section.

What's the correct PHP to use to create this?


<li>
<div class="avatar" style="background: url(http://gravatar.com)></div>
<div class="comment">This is a comment.</div>
</li>

Answers (1)

2011-02-11

Andrzej answers:

put this to your functions.php:

function my_get_avatar_filter($avatar_html) {
$exp1 = explode("src='", $avatar_html);
$exp2 = explode("'", $exp1[1]);
return $exp2[0];
}


and this in comments template:
<li>
<div class="avatar" style="background: url(<?php echo my_get_avatar_filter(get_avatar($comment)) ?>);"></div>
<div class="comment">This is a comment.</div>
</li>