QNimate

  • CoursesVideos
  • WP PremiumPlugins
  • DemosLab
  • Home
  • QIdea
  • QTrack
Home Carbon Ads Change WordPress Default Avatar

Change WordPress Default Avatar

WordPress themes while displaying author bio and comments use the get_avatar function to retrieve the avatar.

get_avatar function requests avatar from Gravatar. If gravatar returns a image then get_avatar functions returns that image otherwise returns the default image. WordPress by default provides some default images, you need to select any one. You can also add more default images using this code

add_filter( 'avatar_defaults', 'newgravatar' );

function newgravatar ($avatar_defaults)
{
    //url of the avatar
    $myavatar = "http://qnimate.com/wp-content/uploads/2015/03/unknown.png";
    $avatar_defaults[$myavatar] = "Anonymous";
    return $avatar_defaults;
}

On Settings › Discussion page you would see this

Screen Shot 2015-03-11 at 11.38.19 pm

In either cases get_avatar function passes the final image through the get_avatar filter before returning the image.

Note: If you have disabled avatar on Settings › Discussion page then get_avatar function simply returns false and doesn’t do any of the above stuff.

Mar 11, 2015Narayan Prusty
Create a Chat App using Intel XDK and XMPPWordPress Check if Gravatar Exists

Leave a Reply Cancel reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Narayan Prusty

I am a software engineer specialising in Blockchain, DevOps and Go/JavaScript. This is my personal blog where I write about things that I learn and feel interesting to share.

7 years ago WordPress
Share this
0
GooglePlus
0
Facebook
0
Twitter
0
Linkedin
Related Articles
  • WordPress Remove Avatar from Comments Only
  • WordPress Enable Automatic Theme Updates
  • WordPress Filter Final HTML Output
  • WordPress Freelance Plugin Widget
  • WordPress Enable Automatic Plugin Updates
Our Sponsor
My Books

2014 - 2015 © QNimate
All tutorials MIT license