WordPress.org

Ready to get started?Download WordPress

Forums

How to use Gravatar?! (27 posts)

  1. Redge
    Member
    Posted 9 years ago #

    Hi!

    I want to use gravatar in my template. I know I have to put this code : <img src="<?php gravatar() ?>" alt="" /></img>

    in the comment template. But god, where? I'm not using the default them nor the classic one. So the code insn't the same.

    Whats all the step to implement gravatar in you blog? I've already look at http://www.gravatar.com/implement.php?PHPSESSID=7fb4b0fdc25a1f9cc9261052f48ca8be#section_2_2 and it was no help at all, beleave me!

    Also, do I have to put something in the CSS template?

    This is not simple at all!

  2. tjinh200
    Member
    Posted 9 years ago #

    i'm not entirely certain, as i haven't looked into this further, but i would suggest taking note of the PHP instructions on the link you provided (they are a bit down on that page)...

  3. davincim
    Member
    Posted 9 years ago #

    Redge,

    Go to your comments.php file and find the following:


    <ol class="commentlist">

    <?php foreach ($comments as $comment) { ?>

    <li class="<?=$oddcomment;?>"

    I put the line of code you're referring to just beneath this and it worked like a charm.

  4. Redge
    Member
    Posted 9 years ago #

    Davincim,

    I do have the <li class="<?=$oddcomment;?>" line but not the <ol class="commentlist"> and <li class="<?=$oddcomment;?>"

    So here my complete code of comments.php :

    <div id="comments">

    <?php if ( !empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) : ?>
    <?php _e('Enter your password to view comments.'); ?>
    <?php return; endif; ?>

    <dl id="comments-block">
    <?php if ( comments_open() ) : ?>
    <dd style="margin: 0px; padding: 0px;">
    <p style="margin: 0px; margin-bottom: 1em; padding: 0px;"><b><?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?> so far</b>
    <?php else : // If there are no comments yet ?>
    <?php endif; ?>
    <?php if ( comments_open() ) : ?>

    ">Leave a comment
    <?php endif; ?>

    <?php if ( $comments ) : ?>

    <?php $myvar=0; ?>
    <?php foreach ($comments as $comment) : ?>
    <?php $myvar++; ?>
    <?php if ($myvar == 1) {$swap = "background-color: #eeeee6; padding: 5px;";} ?>
    ">
    <div class="commentBox" style="<?php echo $swap; ?>">

    <?php comment_text() ?>

    <p class="post-footer" style="margin-bottom: 0px; padding-bottom: 0px;">By <?php comment_author_link() ?> on <?php comment_date('m.d.y') ?> <?php comment_time() ?> <?php edit_comment_link(__("e"), ''); ?>
    </div>

    <?php if ($myvar == 1) {$myvar = -1; $swap = "background-color: #e5e5e5; padding: 5px;";} ?>
    <?php endforeach; ?>

    <?php else : // If there are no comments yet ?>

    <?php endif; ?>
    </dd>
    </dl>

    <div class="right"><?php comments_rss_link(__('RSS feed for comments on this post.')); ?>
    <?php if ( pings_open() ) : ?>
    " rel="trackback"><?php _e('TrackBack URI'); ?>
    <?php endif; ?>
    </div>


    <?php if ( comments_open() ) : ?>
    <b><?php _e('Leave a comment'); ?></b>
    <?php _e("Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:"); ?> <?php echo allowed_tags(); ?>

    <form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

    <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="15" tabindex="1" />
    <label for="author"><?php _e('Name'); ?></label> <?php if ($req) _e('(required)'); ?>
    <input type="hidden" name="comment_post_ID" value="<?php echo $post->ID; ?>" />
    <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" />

    <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="15" tabindex="2" />
    <label for="email"><?php _e('E-mail'); ?></label> <?php if ($req) _e('(required)'); ?>

    <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="15" tabindex="3" />
    <label for="url"><?php _e('URI'); ?></label>

    <label for="comment"><?php _e('Your Comment'); ?></label>

    <textarea name="comment" style="border: 1px solid #000;" id="comment" cols="40" rows="6" tabindex="4"></textarea>

    <input name="submit" id="submit" type="submit" tabindex="5" value="<?php _e('Say It!'); ?>" />

    <?php do_action('comment_form', $post->ID); ?>
    </form>

    <?php else : // Comments are closed ?>

    <?php endif; ?>
    </div>

    <!-- Begin #comments -->
    <!-- ItemPage>
    <div id="comments">

    <BlogItemCommentsEnabled>
    <h4><$BlogItemCommentCount$> Comments:</h4>
    <dl id="comments-block">
    <BlogItemComments>
    <dt class="comment-poster" id="c<$BlogCommentNumber$>">">
    <$BlogCommentAuthor$> said...
    </dt>
    <dd class="comment-body">

    <$BlogCommentBody$>
    </dd>
    <dd class="comment-timestamp">" title="comment permalink"><$BlogCommentDateTime$>
    <$BlogCommentDeleteIcon$>
    </dd>
    </BlogItemComments>
    </dl>
    <p class="comment-timestamp">

    <$BlogItemCreate$>

    </BlogItemCommentsEnabled>
    <p class="comment-timestamp">
    "><< Home

    </div>

    </ItemPage -->

    <!-- End #comments -->

  5. Redge
    Member
    Posted 9 years ago #

    Any ideas?

  6. tjinh200
    Member
    Posted 9 years ago #

    have you tried putting it beneath the <li class="<?=$oddcomment;?>" line?

  7. Redge
    Member
    Posted 9 years ago #

    No because there is no <li class="<?=$oddcomment;?> in my comments.php

    I'm using the MinimaPlus Theme

  8. iand
    Member
    Posted 9 years ago #

    Try near <$BlogCommentAuthor$> which is where the name of the commenter is displayed.

  9. Redge
    Member
    Posted 9 years ago #

    Ok Ive put it like this : <$BlogCommentAuthor$><img src="<?php gravatar() ?>" alt="" /></img> said...

    But it's not working...

  10. Redge
    Member
    Posted 9 years ago #

    It's not working. Do I have to put something between theses tags? I mean, wheres the ><

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

  11. iand
    Member
    Posted 9 years ago #

    I don't think the </img> is necessary. Have you got the plugin installed and activated properly?

  12. Redge
    Member
    Posted 9 years ago #

    Yes i did

  13. Redge
    Member
    Posted 9 years ago #

    And I've put this code <img src="<?php gravatar() ?>" alt="" /> right after <$BlogCommentAuthor$> and gravatar don't show up!

  14. holographic
    Member
    Posted 9 years ago #

    mine is just before the <?php comment_text() ?>, if that's any use to you

    by the way, all that <$BlogCommentAuthor$> stuff at the bottom of the code you posted- what does that do? Looks like MT tags to me, but I could be wrong

  15. iand
    Member
    Posted 9 years ago #

    My last suggestion for now (its 1am) - View the source on your comments page - see if anything shows up - that will tell you if the plugin is working. Also I suggest putting the call as <?php gravatar("R", 40, "http://path to no gravatar image.jpg", "FF0000"); ?> That way something should appear.
    The URI of your site might help too.

  16. Redge
    Member
    Posted 9 years ago #

    Ok I'll try this and IanD, my URI is http://pfinal.com

  17. Redge
    Member
    Posted 9 years ago #

    Damn, all i get it error....

    I'm using the MinimaPlus theme by Theron Parlin
    You can found the theme here : http://www.thoughtmechanics.com/templatefiles/v2.2/download.php?get=MinimaPlus.zip

  18. Dalby
    Member
    Posted 9 years ago #

    I had a lot trouble getting it to work because of my limited knowledge of PHP etc

    I don't use your theme but in the end I got it to work in my comments.php like this:

    <?php foreach ($comments as $comment) : ?>
    <li class="<?=$oddcomment;?>">
    a name="comment-<?php comment_ID() ?>"> <img src="<?php gravatar(r,60); ?>" align="right"/> <?php comment_favicon(); ?> <?php comment_author_link() ?> Commented
    a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?> <?php edit_comment_link('e','',''); ?>

    Hope that's of some help.

  19. iand
    Member
    Posted 9 years ago #

    Find this in comments.php:
    <p class="post-footer" style="margin-bottom: 0px; padding-bottom: 0px;">By <?php comment_author_link() ?> on <?php comment_date('m.d.y') ?> <?php comment_time() ?> <?php edit_comment_link(__("e"), ''); ?>
    </div>

    Change it to:
    <p class="post-footer" style="margin-bottom: 0px; padding-bottom: 0px;">By <img src="<?php gravatar() ?>" alt="" /></img><?php comment_author_link() ?> on <?php comment_date('m.d.y') ?> <?php comment_time() ?> <?php edit_comment_link(__("e"), ''); ?>
    </div>

    See if that works.

  20. Redge
    Member
    Posted 9 years ago #

    Oh yeah! It worked when I put <img src="<?php gravatar(r,60); ?>" align="right"/> after <?php comment_author_link() ?>

    But now the problem is how the gravatar is displayed. Look at my web site et http://www.pfinal.com and you'll see what i'm talking about

  21. iand
    Member
    Posted 9 years ago #

    Got it displaying it least. CSS is not my forte though so I can't be of much help there I'm afraid. You probably need something like .post-footer img {clear:both} or something. I really don't know though. Good luck! :)

  22. Jinsan
    Member
    Posted 9 years ago #

    very interesting thread - it seems more useful than the actual gravatar instructions. Will give this a go myself :)

  23. Redge
    Member
    Posted 9 years ago #

    Thanks a lot IanD you've been very helpfull not only for me but for everyone out there whos trying to figure out how to do it!

    Thanks again!!

  24. Jinsan
    Member
    Posted 9 years ago #

    well installed it first time, got it working first time. Redge, I added a div before and after the gravatar code and then edited the css within the style sheet for class. That should help with your alignment

    EDIT: looks like you got it working anyway :)

  25. Redge
    Member
    Posted 9 years ago #

    Yep ! I've changed the image from 60 to 40!

  26. Jinsan
    Member
    Posted 9 years ago #

    well if you still want it at 60 add the div and you can play with the styling - though reducing the size is probably for the best :)

  27. Redge
    Member
    Posted 9 years ago #

    I will add the div!

    For averyone who wonder how add gravatar in the MinimaPlus Theme look for this part in the comments.php :

    <div class="commentBox" style="<?php echo $swap; ?>">

    <?php comment_text() ?>

    <p class="post-footer" style="margin-bottom: 0px; padding-bottom: 0px;">By <?php comment_author_link() ?> on <?php comment_date('m.d.y') ?> <?php comment_time() ?> <?php edit_comment_link(__("e"), ''); ?>
    </div>

    Before <?php comment_text() ?> simply add this code : <img src="<?php gravatar(r,60); ?>" align="right"/>

    And your done!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.