> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Adding a default gravatar on WordPress

> Learn how to add a default gravatar on WordPress. This article shows you how to add a new default gravatar with a short code snippet.

Globally Recognized Avatar or Gravatar is a [WordPress](https://hosting.com/hosting/platforms/wordpress-hosting/managed-wordpress-hosting/) ’s avatar system which allows an avatar image displayed next to comments made by the user on any WordPress site. The image icon can be a brand representing your company and brand. [WordPress](https://hosting.com/hosting/platforms/wordpress-hosting/managed-wordpress-hosting/) comes with a series of default gravatar; this guide shows you how to upload a custom image and use it as the default gravatar in WordPress instead of the default image placeholder.

## Upload an image for  gravatar in WordPress

To upload image to Media library,  follow these steps:

1. Log in to your WordPress site with an administrator account.

2. On the **Dashboard** in the left sidebar, click **Media**:\
   ![](https://static.hosting.com/kb/kb-wp-defaultgravatar-3.png)

3. Click on **Add New**, and then click on **Select Files** to select and upload an gravatar image:\
   ![](https://static.hosting.com/kb/kb-wp-defaultgravatar-13.png)

4. The new gravatar image is listed on the **Media Library**:\
   ![](https://static.hosting.com/kb/kb-wp-defaultgravatar-11.png)

5. Click on the image, copy the File URL. This URL will be used in the code snippet in the upcoming sections:\
   ![](https://static.hosting.com/kb/kb-wp-defaultgravatar-8.png)

## Add a default gravatar in WordPress

To add a default gravatar,  follow these steps:

1. On the **Dashboard** in the left sidebar, click **Appearance**, and then click **Theme Editor**:\
   ![](https://static.hosting.com/kb/kb-wp-defaultgravatar-5.png)

<Warning>
  **Important**

  You will not be able to roll back to your earlier Theme configuration after any edits. Make a copy of  the Theme file before proceeding with the edits.
</Warning>

2. On the **Theme Editor**, select the **Theme** you want to edit from the dropdown:\
   ![](https://static.hosting.com/kb/kb-wp-defaultgravatar-1.png)

3. The files for this selected theme are listed on the right column under **Theme Files**. Click on the file named "functions.php":\
   ![](https://static.hosting.com/kb/kb-wp-defaultgravatar-6.png)

4. Insert the following code to the end of functions.php file:

```javascript theme={null}
add_filter( 'avatar_defaults', 'custom_gravatar' );

function custom_gravatar ($avatar_defaults) {

$myavatar = 'http://YOUR_WORDPRESS.COM/images/custom_gravatar.png';

$avatar_defaults[$myavatar] = "Default Gravatar";

return $avatar_defaults;

}
```

5. Copy the URL from Step 5 in*Upload an image for  gravatar* and replace URL for *\$myavatar* in the function.Click Update File button to update the file.

````javascript theme={null}
add_filter( 'avatar_defaults', 'custom_gravatar' );

function custom_gravatar ($avatar_defaults) {

$myavatar = 'http://YOUR_WORDPRESS.COM/images/custom_gravatar.png'; //replace this with your the image URL

$avatar_defaults[$myavatar] = "Default Gravatar";

return $avatar_defaults;

}
```![](https://static.hosting.com/kb/kb-wp-defaultgravatar-2.png)

## View the default gravatar in WordPress

To view the default gravatar in WordPress, follow these steps:

1. On the **Dashboard** in the left sidebar, click **Settings**, and then click **Discussion**:
![](https://static.hosting.com/kb/kb-wp-defaultgravatar-9.png)

2. Scroll down to the **Default Avatar** section to view the new default Avatar:
![](https://static.hosting.com/kb/kb-wp-defaultgravatar-10.png)

3. Select the new gravatar and click on **Save Change**:
![](https://static.hosting.com/kb/kb-wp-defaultgravatar-7.png)

4. The gravatar will be displayed beside the username:
![](https://static.hosting.com/kb/kb-wp-defaultgravatar-12.png)

## Related articles

- [Carousel Slider for WordPress](/docs/carousel-slider-for-wordpress) 

- [Adding a custom logo to WordPress](/docs/adding-a-custom-logo-to-wordpress)

 
````
