WordPress is a well-liked content management system that makes it simple to build and maintain websites. Displaying Gravatars on your website is one of the benefits of WordPress.
When a person comments on or interacts with your website, a Gravatar, a well known avatar, shows next to their name. It’s a terrific way to add personality to your website and increase user engagement. We’ll demonstrate how to display Gravatars from user emails in WordPress in this blog article.
What is Gravatar?
With the help of the service Gravatar, users may make a profile image that can be used on several websites. Users submit a profile image and link it to their email address when they join up for Gravatar. In this way, their photo will always be shown next to their comment anytime they leave one on a website that accepts Gravatar. With the help of Gravatar, you can easily customise your online persona and increase your chances of being recognized on many platforms.
Step 1: Install and Activate the Gravatar Plugin
The WP User Avatar plugin has to be installed and activated initially. You may utilize Gravatars as user avatars in WordPress with the help of this plugin. To install the plugin, navigate to the Plugins tab in your WordPress dashboard, select “Add New,” and then type “WP User Avatar” into the search bar. Activate and install the plugin.
Step 2: Enable Gravatar Support
After installing and turning on the plugin, you must allow Gravatar support. Go to Settings Discussion in your WordPress dashboard to accomplish this. Check the box next to “Show Avatars” in the “Avatars” section by scrolling down. Next, from the “Default Avatar” selection option, choose “Gravatar Logo.” Save your edits.
Step 3: Display Gravatars on Your Website
You may now show Gravatars on your website because you’ve enabled Gravatar support. You must modify the comments.php file in your theme to do this. Copy the comments.php file from the default WordPress theme and add it to your theme if it doesn’t already have one.
Open the comments.php file in a text editor and look for the following code:
<?php echo get_avatar( $comment, 60 ); ?>
This code displays the user’s avatar using the default WordPress avatar system. To display the Gravatar instead, replace the code with the following:
<?php echo get_avatar( $comment, 60, '', '', array('scheme' => 'https') ); ?>
This code tells WordPress to use the Gravatar system and to use HTTPS for the avatar URL. Save your changes to the comments.php file.
Step 4: Test Your Gravatar
Visit your website and post a comment there using an email address connected to your Gravatar account to test it out. Your comment should be accompanied by your Gravatar.
WordPress’s ability to display Gravatars from user emails is a terrific way to give your website a more unique feel and increase user engagement. You can quickly install Gravatar support on your website and start showing Gravatars for your users by following the instructions provided in this blog article. Your website will be more hospitable and appealing with Gravatars, which can increase interaction and improve the user experience. If you want to do your WordPress website, you can check our services.