Do you find the default avatars options in WordPress inadequate?
Here is an example on how to add a new custom avatar to the default selection of avatars in WordPress – and it is actually quite simple :)
The below code should be added to your functions.php file in your theme folder – if you are using a child-theme, just add the code to the functions.php in the child folder. Upload a quadratic image that fits your needs in size, change the string PATH-TO-YOUR-CUSTOM-AVATAR to the path (url) of your avatar image. Give it a nice name by replacing the string NAME-OF-NEW-DEFAULT-AVATAR-OPTION.
/** * Adding new default avatar option to WordPress */ if ( !function_exists('addCustomAvatar') ) { function addCustomAvatar( $avatar_defaults ) { $myavatar = 'PATH-TO-YOUR-CUSTOM-AVATAR'; $avatar_defaults[$myavatar] = 'NAME-OF-NEW-DEFAULT-AVATAR-OPTION'; return $avatar_defaults; } add_filter( 'avatar_defaults', 'addCustomAvatar' ); }
All done… Enjoy!
NOTE: This approach works in “WordPress 3.3.2”