Beruflich Dokumente
Kultur Dokumente
Search WordPress.org
Home Page
Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!
WordPress Lessons
Getting Started
How to Use Gravatars in WordPress
Working with WordPress
Developer Docs
When browsing different web sites, you may notice that many users have a picture next 1 What is a Gravatar?
to their name. These pictures are called "avatars." WordPress, however, uses a specific About WordPress
2 Why use Gravatars?
type of avatar called "Gravatars"--short for "Globally Recognized Avatar." Unlike 2.1 Benefits for Administrators
standard avatars, Gravatars follow you around the web and automatically appear when 2.2 Benefits for Users Codex Resources
you post a comment on a WordPress site. 3 Using Gravatars on your Site Community portal
CSS Help
4.3 Create a Custom Default
Avatar
4.4 Using Gravatar’s Hovercards
4.5 Resources
WordPress integrates Gravatars into every WordPress site. Once registered with
Gravatar, the service matches your WordPress profile information to the email address
registered with Gravatar and displays your custom Gravatar image next to comments and (optionally) elsewhere on the WordPress
site. If you choose not to sign up with Gravatar, the default icon set by the Administrator appears next to your name.
For Developers
https://codex.wordpress.org/How_to_Use_Gravatars_in_WordPress 1/4
For Developers
30/12/2017 How to Use Gravatars in WordPress « WordPress Codex
Starting with WordPress 2.7, when you retrieve the comments on a post or page using wp_list_comments, WordPress will
automatically retrieve your users' Gravatars. If you would like to retrieve a user's Gravatar without retrieving comments, you can use
get_avatar.
For example, to return a 50px x 50px Gravatar, you would call wp_list_comments like this:
get_avatar works slightly different. The first argument you pass it must be a user's ID, email address or the comment object. You
can then specify the size of the returned Gravatar, the URL for the default image you want to display if a user does not have a
Gravatar, and the alternate text for the Gravatar image.
As the Twenty Eleven theme demonstrates, you can simply use an additional class to target a specific instance of a Gravatar.
This will change the display of Gravatars only in the Twenty Eleven theme's comments:
.comment-list .avatar {
/*Insert
Your
Styling
Here */
}
After uploading the new image to your theme files, add this to your theme’s function.php file:
<?php
add_filter( 'avatar_defaults', 'new_default_avatar' );
Now, go to Settings > Discussion and select your new avatar from the list.
https://codex.wordpress.org/How_to_Use_Gravatars_in_WordPress 2/4
30/12/2017 How to Use Gravatars in WordPress « WordPress Codex
From now on, all your users that don't use Gravatar will have this avatar next to their comments.
Resources
Introducing Gravatar
Gravatar Profiles
Using Gravatars
Gravatar Developer Resources
HiDPI Gravatars
Categories:
WordPress Lessons
Working with WordPress
Follow @WordPress
https://codex.wordpress.org/How_to_Use_Gravatars_in_WordPress 3/4
30/12/2017 How to Use Gravatars in WordPress « WordPress Codex
https://codex.wordpress.org/How_to_Use_Gravatars_in_WordPress 4/4