Learn how to add a custom user avatar in Genesis Framework child theme comments using code.
By default, WordPress offers 7 different avatar icons that are displayed when the user does not have a Gravatar account of their own.
Not convinced by any of the options WordPress gives you? Do you want to give it a more personal touch? You can create an original avatar by taking advantage of a Genesis filter.
In fact, this is one of those little changes that help take care of your brand image. If a user doesn’t have his or her own, it’s better to show the web’s logo than a random icon, for example.
Snippet to add a custom avatar
Add the following fragment at the end of the functions.php file:
With this code you register a new avatar with the name “Custom Avatar” which is included at the end of Settings -> Comments -> Default Avatars.
Now you only have one step left.
Upload the new avatar image to the /images/ folder of your Genesis child theme. The file should be called “personalized-avatar.png” and have a 48×48 pixel size.
Of course, you can use any name you want as long as you modify it in the previous snippet as well.
If you have modified the size of the comment gravatar, make sure you use those same parameters.
As you can see, by adding a few simple lines of code you can add a custom avatar to the comments in any Genesis child theme and help take care of the brand image.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂