How to Set Your Own Default Gravatar in WordPress


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

Add the following code to the end of the functions.php file. Et voilà !


Copy this code and paste it in your HTML
  1. function add_custom_gravatar ($avatar) {
  2. $custom_avatar = get_bloginfo('template_directory') . '/images/name-of-your-custom-gravatar.jpg';
  3. $avatar[$custom_avatar] = "Gravatar name to be shown in the WordPress settings"; //change this name to your preferences
  4. return $avatar;
  5. }
  6. add_filter( 'avatar_defaults', 'add_custom_gravatar' );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.