Wordpress - Custom Default Avatar

/ Published in: PHP
Save to your folder(s)

Add the following to your active theme's functions.php file then upload an image named "avatar.jpg" to your active theme's image folder. The image can be named anything you would like but be sure to change it in the code below as well.

The last step is to visit: Settings > Discussion to select the new avatar as the default.

Copy this code and paste it in your HTML
  1. // Add a default avatar to Settings > Discussion
  2. if ( !function_exists('fb_addgravatar') ) {
  3. function fb_addgravatar( $avatar_defaults ) {
  4. $myavatar = get_bloginfo('template_directory') . '/images/avatar.jpg';
  5. $avatar_defaults[$myavatar] = 'Doc4';
  7. return $avatar_defaults;
  8. }
  10. add_filter( 'avatar_defaults', 'fb_addgravatar' );
  11. }

URL: http://wordpress.org/support/topic/custom-default-avatar

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.