Support » Themes and Templates » Can’t change default Gravatar

Viewing 3 replies - 1 through 3 (of 3 total)
  • Given that the error code was one line 1, did you ensure that you added your changes after the opening <?php tag in functions.php? Did you inadvertently duplicate the opening <?php tag?

    Tosh

    (@xberserker)

    I put both methods after the <?php tag. No I didn’t duplicate it either. I actually changed the default gravatar using method 1 on my community site with success. I would prefer method 1 myself, but whatever works I guess.

    Method 1 is to put this in the functions.php file like so:

    add_filter( 'avatar_defaults', 'newgravatar' );
    
    function newgravatar ($avatar_defaults) {
        $myavatar = get_bloginfo('template_directory') . '/images/buildinternet-gravatar.jpg';
        $avatar_defaults[$myavatar] = "Build Internet";
        return $avatar_defaults;
    }

    Method 2 is to change this:

    <?php if(function_exists(’get_avatar’)){ echo get_avatar($comment, 50 );} ?>

    to this

    <?php if(function_exists(’get_avatar’)){ echo get_avatar($comment, 50, ‘http://www.wphacks.com/wp-content/themes/HackWordPressPro/images/nophoto.gif’);} ?>

    Tosh

    (@xberserker)

    I tried this method again. But placed it at the end of the functions.php file instead and it works now.

    Right after this:

    <?php
    } // </li> is added by wordpress

    but before ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t change default Gravatar’ is closed to new replies.