Wordpress: Customize Default Gravatars


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



Copy this code and paste it in your HTML
  1. /**
  2.  * Customize Default Gravatars
  3.  * http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/
  4.  *
  5.  **/
  6. function myfunction_custom_gravatars($avatar_defaults) {
  7.  
  8. // change the default gravatar
  9. $customGravatar1 = get_bloginfo('template_directory').'/images/gravatar-01.png';
  10. $avatar_defaults[$customGravatar1] = 'Default';
  11.  
  12. // add a custom user gravatar
  13. $customGravatar2 = get_bloginfo('template_directory').'/images/gravatar-02.png';
  14. $avatar_defaults[$customGravatar2] = 'Custom Gravatar';
  15.  
  16. // add another custom gravatar
  17. $customGravatar3 = get_bloginfo('template_directory').'/images/gravatar-03.png';
  18. $avatar_defaults[$customGravatar3] = 'Custom gravatar';
  19.  
  20. return $avatar_defaults;
  21. }
  22. add_filter('avatar_defaults', 'myfunction_custom_gravatars');

URL: http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.