How to change default Gravatar for comments

Marc van Leeuwen

Premium Member
Joined
May 29, 2016
Messages
1,132
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
0
Views
591
Replies
2
Views
791
Recommended threads
Replies
5
Views
948
Replies
3
Views
2,547
Replies
2
Views
3,727
Replies
4
Views
2,126
Replies
3
Views
1,315

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