WordPress.org

Forums

Should Gravatars Work "out of the box" in 2.5? (14 posts)

  1. waynefrost
    Member
    Posted 7 years ago #

    I recently upgraded from 2.0.2 to 2.5 and see that there are settings for gravatars on the Setup/Comments page. I have registered a gravatar and tried poosting a comment, but the gravatar does not display. Do I need a plugin for gravatars on 2.5 or should 2.5 support gravatars already?

  2. knightlore
    Member
    Posted 7 years ago #

    I have this as well. if I view the comments via the admin dashboard then I can see my gravatar however if I view comments through the blog then I cannot see Gravatars. Anyone have any ideas??

  3. lexhair
    Member
    Posted 7 years ago #

    You need a plugin for gravatars to appear in your comments. I use Dougal's Easy Gravatars.

  4. moshu
    Member
    Posted 7 years ago #

    Also, good reading: Using_Gravatars

  5. knightlore
    Member
    Posted 7 years ago #

    I have added the code to the comments.php in the theme I am using and it works fine

  6. lexhair
    Member
    Posted 7 years ago #

    I modified my comments.php but trying to style my theme to get it to render nicely gave me a headache. I went back to the plugin which let me style the gravatar quite easily.

  7. waynefrost
    Member
    Posted 7 years ago #

    Thanks lexhair & moshu, I'll give the plugin a shot, but not for a while, trying to withold adding new plugins until 2.5 seems more stable overall, I don't want to muddy the waters while trying to resolve some other issues.

  8. lexhair
    Member
    Posted 7 years ago #

    I went back to a modified comments.php. I wrapped the get_avatar function in a unique div class tag and it was much easier to style.

  9. Gravatars are in 2.5 by default and how to use them is in the default theme as well, but they will not be enabled in your older custom themes until you do so.

    Here's what I did to enable them in mine. You can use this as an example, to get an idea of how to do it.

    Basically, I wanted them to show up next to the comments. So I edited my comments.php file. First I found this code in it:
    <cite><?php comment_author_link() ?></cite> Says:
    That prints the "Otto says:" bit in my comment. Just in front of that, I added this:

    <?php if (function_exists('get_avatar')) : ?>
    <a href="http://gravatar.com">
    <?php echo get_avatar($comment, 40); ?>
    </a>
    <?php endif; ?>

    Like most themes, my theme used "$comment" as the variable for the individual comment. Look for code like this in the file: foreach( $comments as $comment ) {. The $comments name is set by WordPress, but the individual $comment name is determined by the theme. $comment is the usual case.

    And the "40" is the size I wanted the avatar to be, in my theme. 40 pixels was derived by experimenting with different values until I liked it.

    Also note that I made the avatar link to gravatar.com. I did this so that if somebody clicks on the avatars, they will discover how to get their own. So if somebody leaves a comment and sees their avatar is the default, then clicking on it will lead them to a place where they can create an avatar for themselves to see.

    Now, this put the avatar in there, but the text was screwy. My comment didn't flow around it properly, and didn't leave enough margin space. But, I discovered that the get_avatar function adds a class of "avatar" to what it produces. So styling it was easy, by adding this to my stylesheet:

    .avatar {
    float:left;
    padding: 3px;
    margin-bottom: 5px;
    }

    The float:left makes text wrap around it properly, and the padding and margin makes the text stand away from it a little bit. Again, experimentation helped to determine how I wanted this to work.

    And that's it. It's pretty easy if you know where you want it to be. No need for a plugin, just a minor bit of theme editing.

  10. mmmichaels
    Member
    Posted 6 years ago #

    I've just (well I think I have) sorted out Gravatars on my website thecheesegrater.co.uk

    I installed Easy Gravatars, but I think that it's built in standard so I'm not currently using a plugin, if anyone cares to leave a comment that has gravatars set up we can find out.

  11. mmmichaels
    Member
    Posted 6 years ago #

    ok 2.6.3 works, I've just tested it myself. So all your gonna wanna do is change the default pic.

  12. peterassmann
    Member
    Posted 6 years ago #

    thank you. i tried to add gravatars on my page prepaid-pakete.org after i had rewritten it so it should have worked on my site... but it didnt... well bad luck i'll try another thing...

  13. chiahau
    Member
    Posted 6 years ago #

    Thanks lexhair & moshu, I hope that I will give your plugin a shot in the near future. But can't possibly do that now cause I already have too much plugin on my site as it is. So your would have to wait a little longer I guess.

  14. CristianRa
    Member
    Posted 6 years ago #

    @lexhair & moshu & chiahau thanks guys.
    I'm still using a version prior to 2.5 on my foam board insulation blog. I guess I'll have to update asap ... heh.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags