WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Gravatar as poster (36 posts)

  1. icco
    Member
    Posted 9 years ago #

    I recently started using gravatar, and im wondering if anyone knows a way to make it so you can have an icon next to the post to show who posted it.

  2. NuclearMoose
    Member
    Posted 9 years ago #

    The Gravatar site has instructions for doing this.

  3. icco
    Member
    Posted 9 years ago #

    really? would you mind pointing it out i cant seem to find it.

  4. xaos
    Member
    Posted 9 years ago #

  5. icco
    Member
    Posted 9 years ago #

    ya but how do i apply this to the poster of the article not the comment.

  6. icco
    Member
    Posted 9 years ago #

    bump, is this possible?

  7. Lynne_ydw_i
    Member
    Posted 9 years ago #

    The logical place to put it would be in the index.php before or after
    <?php the_author() ?> but I just tried and it didn't show up.

  8. icco
    Member
    Posted 9 years ago #

    hmm ok thanks for trying.

  9. Ozh
    Member
    Posted 9 years ago #

    Insert the following (within the loop, of course)
    $grav_email=$authordata->user_email;
    $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($grav_email)."&amp;default=".urlencode($default)."&amp;size=".$size;
    echo "<img src=\"$grav_url\" alt=\"gravatar\"/>" ;

  10. icco
    Member
    Posted 9 years ago #

    umm im not exactly sure what the loop is. thanks for the answer though.

  11. icco
    Member
    Posted 9 years ago #

    OK i think that that response i made is a litttle to general. Im wondering now if i put that in the index page or the plugin page, and where on those pages i should put it.

  12. lawtai
    Member
    Posted 9 years ago #

    You can do this without using gravatar if you want. I was able to figure it out for my site without gravatar.

  13. icco
    Member
    Posted 9 years ago #

    well i could put an image next to my name, but i would like it to be the same as the image from gravatar

  14. ryoken
    Member
    Posted 9 years ago #

    okay, enclose that little bit in <?php and ?> and place it in the code of your index page wherever you want the image to be display. if you are using 1.5, add it to the index of your theme and into whatever other templates you want with the image.

  15. icco
    Member
    Posted 9 years ago #

    so this is what i have right now, but nothing is showing up...

    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>">" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></h3>
    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category() ?> — <?php $grav_email=$authordata->user_email;
    $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($grav_email)."&default=".urlencode($default)."&size=".$size;
    echo "<img src=\"$grav_url\" alt=\"gravatar\"/>" ; the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>

    o ya im using wp 1.2.2

  16. ryoken
    Member
    Posted 9 years ago #

    a gravatar is there but its not choosing the right one. that php code supplied is wrong cuz while it does call the correct image when i try to load it in a new window it somehow doesn't show up right on your site. add #content div.post div.meta img { height: 80px;} to your css to see the "blank gravatar" being called.

  17. icco
    Member
    Posted 9 years ago #

    oi. now how do i get that blank gravat gone and replace it with the right one?

  18. icco
    Member
    Posted 9 years ago #

    bump

  19. icco
    Member
    Posted 9 years ago #

    i found the bug in your php. its amazingly simple :)

    you need to put this wherever you want your image

    <?php $grav_email=$authordata->user_email; $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($grav_email)."&default=".urlencode($default)."&size=40"; echo "<img src=\"$grav_url\" alt=\"gravatar\"/>" ; ?>

    notice the size. you just needed to put a number inside the quotes and it works perfectly :)

    thanks for the help.

  20. jxpx777
    Member
    Posted 9 years ago #

    This post is a little old, but I altered the code on the Gravatar plugin on the Gravatar site to work for post authors. You can visit http://blog.jamiephelps.com/postgravatar/ for this plugin.

    I hesitate to say it's my plugin. I generally just alter other plugins' code for another purpose with very little alteration. If that counts, then this is my second plugin. If not, then I'm a schmuck.

    Godspeed,

  21. icco
    Member
    Posted 9 years ago #

    thats cool, it works too. but just to tell you youve got a few bugs in your comment system :)

  22. davincim
    Member
    Posted 9 years ago #

    Well, once again, I've come across a plug-in that fails to tell you where the code actually goes. :( After reading this thread I can say I'm only a little bit closer.

    If I understand correctly the

    <?php gravatar("R", 40); ?>

    needs to go in an img tag and somewhere within the loop in index.php. Am I right so far? If so, I'm thinking there's an appropriate spot for the code to be placed in there, so where might that be?

    Assuming I am correct, that means that that information is then carried over to the comments page when someone clicks on "comments". So, I know I need a class for gravatar in my stylesheet (which I've added), but what I don't understand is where on the comments page do I tell it "put it right here".

    Here's my test blog.

    ???

  23. davincim
    Member
    Posted 9 years ago #

    bump

  24. Penda
    Member
    Posted 9 years ago #

    No one told me either. People aren't exactly helpful here.

    It doesn't go on your index page, it goes in your wp-comments page

    try this:

    File - wp-comments.php:

    There is a line that says, <!-- You can start editing here. -->.

    In the second group of code which starts: < ?php if ($comments) { ?>, add the gravatar code just after <?php _e("by"); ?> , that way the photo comes up next to the name of the commenter.

    Hope that works

    You can see it in action here:

    http://www.pendasrealm.com/diner/index.php?p=630

  25. davincim
    Member
    Posted 9 years ago #

    Thanks, Penda! I'll give it a try. :)

  26. davincim
    Member
    Posted 9 years ago #

    Ohmygosh, Penda, it worked! I made a few modifications to the instructions you provided, but you at least got me in the right place to make the change.

    Thanks!

  27. icco
    Member
    Posted 9 years ago #

    sorry i didnt respond sooner guys, ive been busy. im not sure whether you are asking about the plugin or the php code, if you want help you need to be specific.

  28. Penda
    Member
    Posted 9 years ago #

    Gee icco - the questions were about as specific as they come - "where does the plugin go". We're not asking for you to hold our hands, I mean, we did install the dang things, just clearer instructions.

    And David - I'm glad it worked out for you.

  29. jxpx777
    Member
    Posted 9 years ago #

    Well, that isn't exactly specific. "Where does the plugin go?" could mean where do I put the plugin file or where do I insert the php code to call the plugin in the template.

    That all being said, the gravatar php code needs to go in an image tag in the comments template (location differs pending your version of WP) inside the comment loop. The plugin I posted about is for the post loop. That's why there has to be a different plugin for post gravatars vs. comment gravatars.

    @icco - What problems do you see with my comment system?

  30. Jinsan
    Member
    Posted 9 years ago #

    jxpx777 were able to fix the problems within your plugin that icco suggests might be there?

    I'd like to use this plugin for post authors on a review site, which would be very useful. However, I may end up using a local image for each author called by the plugin - is this possible with your plugin or will I have to go to the php route?

    @Icco could you advise on how and where you implemented the code?

    Btw, I'm not talking about having a gravatar on a comments area, that I have, just that when a user makes a post it says by: username and then their gravatar/avatar/smhavatar

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.