WordPress.org

Ready to get started?Download WordPress

Forums

gravatar display code issue (19 posts)

  1. richards1052
    Member
    Posted 8 years ago #

    I've just registered for a gravtar & can't figure out how to make it work. Here's my gravatar url:

    http://www.gravatar.com/avatar.php?gravatar_id=aa2859f2616c9fb536509ebc0b6c3529"

    If I understood the directions, you have to insert this within the comment box:

    <img src="<?php gravatar() ?/> alt="" />

    So how should the entire code look when placed within the box? I've tried a few configurations in my own blog comment box & nothing's worked.

  2. Cypher
    Member
    Posted 8 years ago #

    First, download the Gravatar plugin from here

    Install it, and activate it.

    Second, edit your comments.php file and within the comments loop place the code you have in your post and you will see the gravatar appear.

    Regards

  3. skippy
    Member
    Posted 8 years ago #

    You do not add that code when you're leaving a comment.

    Gravatar-enabled sites include that bit of code in their comments template file (/wp-content/themes/<your theme>/comments.php for WordPress).

  4. richards1052
    Member
    Posted 8 years ago #

    OK, I thought I added it inside the comment loop. But after saving the template I saw this error when I clicked on the Comment link in my blog:

    Parse error: parse error, unexpected '/' in /home/richard2/public_html/tikun_olam/wp-content/themes/almost-spring/comments.php on line 22

    So, did I not place it inside the comment loop? I looked for the line that said "you can start editing here" & placed it there as the first line. Was that wrong?

  5. Marc
    Member
    Posted 8 years ago #

    Here is the code from my comment.php, that is also the same theme so it should match yours. You can see the appearence here.

    <?php comment_date('F j, Y') ?>
    @ <a href="#comment-<?php comment_ID() ?>" title="<?php _e('Permanent link to this comment'); ?>"><?php comment_time() ?></a>
    <?php edit_comment_link(__("Edit"), ' · ', ''); ?>

    <div style="clear:both;">

    <strong><div class="img-dec"><img src="<?php gravatar("R", 38, "http://cranialcavity.net/fullthrottle/wp/wp-images/flag-grav.gif",

    "000000"); ?>" alt="" /></div></strong>

    <?php comment_text() ?>
    </li>

    Pay attention to the code between "clear both>" and "php comment text" Look for the same code and enter your gravatar code.

  6. Marc
    Member
    Posted 8 years ago #

    Addendum to the above.

    Sorry I don't think I made that post clear and I can't edit it.

    Between the "clear both" and the "php comment_text" is the code I entered to stley that section the way I desired (ie <div class="img-dec">).

    Look for the code in your comments.php above that section and below it, it should be the same as yours and insert your Gravatar code. Because that blog is using the same theme as yours it shouldn't be a problem locating that section of code.

  7. richards1052
    Member
    Posted 8 years ago #

    Many thanks, Marc. That really helped & now the gravatar is displaying. I didn't add the strong or div class tags or the R/38/000000 items since I wasn't sure whether they corresponded to something special in yr. blog or whether they'd refer to something universal including mine as well.

    If you think they're important I can insert them as well.

    Thanks again.

  8. Marc
    Member
    Posted 8 years ago #

    Check the instruction given with the plugin code. The R/38 tells the plugin to restrict images to a "R" rating and the 30 is the px width of the image.

  9. richards1052
    Member
    Posted 8 years ago #

    Good to know. I think the R is a useful parameter & added it to mine...do you think it matters much whether you use yr. gravatar image hosted on their site or whether you host it on your own? I could do either. If their site is reliable then I suppose it's OK.

  10. Marc
    Member
    Posted 8 years ago #

    You should make a default grav and host it on your own site. It would be called up for for people that don't have one.

    If you look at my site I linked to earlier you can see my default and how it gets called up.

  11. davidbabylon
    Member
    Posted 8 years ago #

    Sorry if this is a silly question but I am running into a very similar problem as richards1052. I installed the Gravatar plugin and activated it. I then placed this gravatar code into the comments section;

    <div class="commentinfo">
    <span class="commentdate">
    <?php comment_date() ?> |
    <" title="comment link url">
    <?php comment_time() ?>

    <?php edit_comment_link(__("Edit This"), ' |'); ?>
    </span>
    </div>
    <div class="clearer"> </div>

    <?php gravatar({rating(), size(), <img src="http://www.davidbabylon.com/images/default_avatar.jpg" alt="Default Avatar" />", "FF0000"}}}}) ?>

    <div class="commenttext">

    After doing this in the comments of all my posts this error came up;

    Parse error: parse error, unexpected '{', expecting ')' in /home/.vamp/davidbabylon/davidbabylon.com/wp-content/themes/rin/comments.php on line 35

    I apologize if this has already been explained in this thread and I simply did not understand but I would appreciate any help anyone might be able to offer me. I am new to php and have found this forum to be a great source of information and all the members very helpful.

    Thanks again.

  12. skippy
    Member
    Posted 8 years ago #

    davidbabylon: try this:
    <?php gravatar('R', '80', <img src="http://www.davidbabylon.com/images/default_avatar.jpg" alt="Default Avatar" />", "FF0000") ?>

    Use the rating and size you really want.

  13. davidbabylon
    Member
    Posted 8 years ago #

    Skippy, thanks for the quick response.
    I entered in the code you suggested and recieved the same error.
    Am I not placing the code in the right spot? Here is where I placed it in the comments.php file;

    <?php edit_comment_link(__("Edit This"), ' |'); ?>
    </span>
    </div>
    <div class="clearer"> </div>
    <?php gravatar('R', '80', <img src="http://www.davidbabylon.com/images/default_avatar.jpg" alt="Default Avatar" />", "FF0000") ?>
    <div class="commenttext">

  14. skippy
    Member
    Posted 8 years ago #

    Take a look again at the example above.

    <img src="<?php gravatar("R", 38, "http://cranialcavity.net/fullthrottle/wp/wp-images/flag-grav.gif", "000000"); ?>" alt="" />

    You're placing the <?php gravatar ...?> bit where you would normally place a URL to an image.

  15. davidbabylon
    Member
    Posted 8 years ago #

    Thanks Skippy. Worked perfectly!

  16. richards1052
    Member
    Posted 8 years ago #

    I recently tried to follow Marc's advice by uploading my own gravatar image hosted on my WP site. Whereas before when I used the gravatar.com image in my php code, the gravatar displayed correctly. Using the image url hosted on my own site somehow caused every single comment on my site to display my gravatar. There's prob. a coding issue here. Can someone help me out by pointing out my mistake?

    <img src="<?php gravatar("R",80, "http://www.richardsilverstein.com/photos/uncategorized/geesbendgravatar.jpg" ,"000000"); ?>" alt="" />

  17. Marc
    Member
    Posted 8 years ago #

    Again, this is the exact code from my blog with the same theme that should be entered. If that is resulting in all your gravs displaying your default image the problem is somewhere else and not with this code. Hint, or not: If an Email addy is not entered on a comment it will display your default grav even if the individual hs a grav of their own.

    <img src="<?php gravatar("R", 38, "http://cranialcavity.net/fullthrottle/wp/wp-images/flag-grav.gif",

    "000000"); ?>" alt="" /></div>

  18. richards1052
    Member
    Posted 8 years ago #

    Yes, I purposely tried to enter the code precisely as you had it since it's working for you--I figured that'd mean it'd work for me. But clearly there's something diff. bet. my WP installation & yours.

    As for comments with or w/o e mail addresses...this comment by a visitor HAS an e mail address but is still displaying my grav: http://www.richardsilverstein.com/tikun_olam/2005/06/typepad-to-wordpress-blog-conversion/#comment-841

    If I can't fix this I'll prob. go back to linking to the gravatar.com link.

  19. richards1052
    Member
    Posted 8 years ago #

    I went back to using the gravatar hosted image & it fixed the problem.

Topic Closed

This topic has been closed to new replies.

About this Topic