Skip to main content
Gravatars can be used anywhere on a WordPress site which requires you to display a user profile. This article shows you how to display Gravatar for a user using their email address.

Adding a gravatar hovercard on WordPress

ImportantAlways perform a backup before you make any changes to the theme files. It will be easier for you to revert your site to its last good known state if you break any codes. Alternatively you could also create a child theme. Read this link on how to create a child theme: https://www.hosting.com/blog/wordpress-child-theme/
To add a gravatar hovercard using email, follow the steps below:
  1. Log in to your WordPress site with an administrator account.
  2. On the Dashboard in the left sidebar, click Appearance, and then click Theme Editor:
ImportantYou will not be able to roll back to your earlier Theme configuration after any edits. It is recommended to save the Theme file before proceeding with the edits.
  1. On the Theme Editor, select the Theme you want to edit from the dropdown:
  2. The files for this selected theme is listed on the right column under Theme Files. Click on the file named “functions.php”:
  3. Insert the following code to the end of functions.php file. The function below is a modified version of the wpbeginner_display_avatar function. The function below creates a shortcode. The shortcode can be used with an email to display the gravatar of the user according to the email address:
  1. To display the gravatar on the page or post use the following shortcode: