WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Tosh
    Member
    Posted 4 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.

    http://buildinternet.com/2009/02/how-to-change-the-default-gravatar-in-wordpress/

    http://wphacks.com/how-to-changing-the-default-wordpress-avatar/

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 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
    Member
    Posted 4 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
    Member
    Posted 4 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:

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

    but before ?>

Topic Closed

This topic has been closed to new replies.

About this Topic