page template - get_avatar() as backround image

admin2025-06-03  3

<div class="kkk" style="background-image:url('<?php echo get_avatar_url(); ?>')"></div>

I want to make to appear my avatar as a backround image in this code, but it doesn't work. What is the problem?

<div class="kkk" style="background-image:url('<?php echo get_avatar_url(); ?>')"></div>

I want to make to appear my avatar as a backround image in this code, but it doesn't work. What is the problem?

Share Improve this question edited Feb 5, 2019 at 17:04 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Feb 5, 2019 at 16:01 AskingAsking 1211 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

It’s hard to say exactly what the problem is with your code, but...

There is at least one major flaw - you don’t pass any param to get_avatar_url, but first param for that function is required and should contain ID or email. To be precise:

$id_or_email (mixed) (Required) The Gravatar to retrieve a URL for. Accepts a user_id, gravatar md5 hash, user email, WP_User object, WP_Post object, or WP_Comment object.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748940532a315005.html

最新回复(0)