[resolved] Can't change default Gravatar (4 posts)

  1. Tosh
    Posted 7 years ago #

    When I try to change the default gravatar by adding some code to the functions.php file in your theme I get this after I upload it.

    Parse error: syntax error, unexpected T_FUNCTION in wp-content/themes/fusion/functions.php on line 1

    I tried change the default gravatar with these 2 different methods. Both show this error above.



  2. esmi
    Forum Moderator
    Posted 7 years ago #

    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?

  3. Tosh
    Posted 7 years ago #

    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');} ?>

  4. Tosh
    Posted 6 years ago #

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

    Right after this:

    } // </li> is added by wordpress

    but before ?>

Topic Closed

This topic has been closed to new replies.

About this Topic