How to change default Gravatar for comments

Marc van Leeuwen

Premium Member
Joined
May 29, 2016
Messages
1,127
Points
63
Some users find the default avatar of WordPress quite annoying. In addition to the specific image on your WordPress will make a bigger impression on the reader. Changing your default avatar will help you promote your brand better. With this code below you can change your default gravatar.

First, you need to open the functions.php located in your template directory. If you do not have this file then create a new one and insert the following code:

Code:
add_filter( ‘avatar_defaults’, ‘newgravatar’ );
 
function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo(‘template_directory’) . ‘/images/gravataricon.gif’;
$avatar_defaults[$myavatar] = "YourBlogName";
return $avatar_defaults;
}
In the code snippet, the image is extracted from the theme folder, and it's called gravataricon.gif, and apparently, you will change it to your image name. That is the name of the avatar in the display area in your admin panel options.
 
Latest threads
Replies
1
Views
271
Replies
0
Views
53
Replies
1
Views
103
Replies
1
Views
99

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top