WORDPRESS CUSTOM DEFAULT GRAVATAR


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

Gives you the option to select a custom gravatar in the Wordpress discussion setting in admin dashboard


Copy this code and paste it in your HTML
  1. //place this in your functions.php file
  2. <?php
  3. add_filter('avatar_defaults', 'newgravatar'); function newgravatar ($avatar_defaults) {$myavatar = get_bloginfo('template_directory') . '/images/default_gravatar.png'; $avatar_defaults[$myavatar] = "yournamehere"; return $avatar_defaults;}
  4. ?>
  5.  
  6. //add this where you want your gravatar, notice the default url "<pathtourl>" removed
  7. <?php echo get_avatar($comment,$size='48',$default='' ); ?></div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.