Add custom avatar to wordpress, this is how to, No plugin just code!

This article was written by in August 5, 2013, & may not be posted on other sites!
Original source url for this article: Add custom avatar to wordpress, this is how to, No plugin just code!

How to add custom avatar to wordpress.
Design and add your own default custom avatar to wordpress, no plugin just code! This image will be used when visitors without a custom avatar of their own leaves a comment. This is how to add a custom deafult avatar in WordPress:

  1. You should always work with a childtheme or a custom theme in WordPress to avoid problems when updating (may cost overwrite) or conflicts with plugins or theme functions.
  2. Create a custom avatar image, It should be sqare size and can be a .jpg or .png for example.
  3. Uppload the custom avatar image into your WordPress theme folder.
  4. Open your theme file > functions.php in a text-editor or through WordPress admin > appearance > editor. If you don’t have a functions.php file, create one and put it directly into your WordPress theme folder.
  5. Ad the following code to your functions.php file:
    <?php
    //custom avatar
    add_filter( 'avatar_defaults', 'custom_avatar' );
    function custom_avatar ($avatar_defaults) {
    $myavatar = get_stylesheet_directory_uri() . '/images/custom-avatar.jpg';
    $avatar_defaults[$myavatar] = "Custom Avatar";
    return $avatar_defaults;
    }
    ?>
  6. Make sure the file path above matches your custom avatar image url.
  7. Save or upload your functions.php.
  8. Inside the WordPress admin, click on settings > discussion and scroll down to the bottom section > Avatars. Your custom avatar should be displayed, just select it and save.

Add custom avatar to wordpress, this is how to, No plugin just code!

Spread the word

Facebooktwittergoogle_pluslinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *