# Adding a default Gravatar in WordPress

> Replace the default WordPress avatar with your own image, such as your logo, for users without a Gravatar.

Source: https://helpcenter.ruachost.com/wordpress/guides/adding-a-default-gravatar-on-wordpress/

WordPress uses **Gravatar (Globally Recognized Avatar)** to display user profile images beside comments and posts. By default, WordPress provides a set of placeholder avatars. On **ruachost.com**, you can replace this with a **custom default gravatar** that better represents your brand or site.

## Why Add a Custom Default Gravatar?

- Strengthens brand identity by showing a logo or custom image.
- Improves site aesthetics compared to generic placeholders.
- Provides a consistent look for users without personal gravatars.

## Steps to Add a Default Gravatar

### 1. Upload Your Image

1. **Log in to WordPress** with an administrator account.
2. Go to **Media → Add New**.
3. Upload your custom gravatar image.
4. Click on the image → Copy the **File URL**.

### 2. Add Code to `functions.php`

1. In the dashboard, go to **Appearance → Theme Editor**.
2. Select your active theme and open the **functions.php** file.
3. Add the following code snippet:

   ```
   // Add custom default gravatar
   add_filter( 'avatar_defaults', 'ruachost_custom_gravatar' );
   function ruachost_custom_gravatar( $avatar_defaults ) {
       $myavatar = 'https://yourdomain.com/wp-content/uploads/2025/11/custom-gravatar.png';
       $avatar_defaults[$myavatar] = "Default Gravatar";
       return $avatar_defaults;
   }
   ```

   - Replace the URL with the File URL copied from your Media Library.
4. Save the file.

### 3. Select Your New Default Gravatar

1. Go to **Settings → Discussion**.
2. Scroll down to the **Default Avatar** section.
3. Select your new gravatar option.
4. Click **Save Changes**.

✅ Your custom gravatar will now appear for users without a personal avatar.

## Important Notes

- Always back up your theme before editing `functions.php`.
- Use a **child theme** to preserve changes during updates.
- Ensure the image is square (e.g., 200×200 px) for best results.
