YPSA Webmaster's Blog

Skip to content Skip to sidebar

How to add custom avatar icon in WordPress

To add custom avatar image in wordpress, pest this code into theme functions.php

/* Add a Custom Default Gravatar */

add_filter( 'avatar_defaults', 'new_avatar' );
function new_avatar($avatar_defaults){
$new_avatar = get_stylesheet_directory_uri() . '/images/avater_icon.jpg';
$avatar_defaults[$new_avatar] = "Theme Default Icon";
return $avatar_defaults;

avater_icon.jpg is your custom icon should be uploaded into theme images folder. Size of this icon can be 80px X 80px size.

To activate your custom icon, go to Discussion panel through dashboard. You will see a new  icon appeared at the end of Default Avatar section. Select it and click save changes.

About the author

Abdullah Al Shakir

I am a web developer and graphics designer have been working in YPSA as webmaster since 2006. I am expert in XHTML, CSS, JavaScript and PHP programming. I am Wordpress theme and plugin developer. I am a father and husband living in Bangladesh.

You may also like

Leave a Reply