Support » Plugins » gravatars-2.6 help

  • Resolved jahangirafzal


    i want to install gravatars-2.6 plugin. bust when ever i edit my comments.php i get errors…. if any one plese help me….. how can i insert this code

    <?php foreach ($comments as $comment) :
    if (function_exists(‘gravatar’)) {
    if (” != get_comment_author_url()) {
    echo “comment_author_url’ title=’Visit $comment->comment_author’>”;
    } else {
    echo “
    echo “<img src='”;
    if (” == $comment->comment_type) {
    echo gravatar($comment->comment_author_email);
    } elseif ( (‘trackback’ == $comment->comment_type) || (‘pingback’ == $comment->comment_type) ) {
    echo gravatar($comment->comment_author_url);
    echo “‘ alt=’a gravatar’ class=’gravatar’ />
    <div id=”commentbox”>


    here’s my “comments.php” file

    <?php // Do not delete these lines
    if (‘comments.php’ == basename($_SERVER[‘SCRIPT_FILENAME’]))
    die (‘Please do not load this page directly. Thanks!’);

    if (!empty($post->post_password)) { // if there’s a password
    if ($_COOKIE[‘wp-postpass_’ . COOKIEHASH] != $post->post_password) { // and it doesn’t match the cookie

    <p class=”nocomments”><?php _e(“This post is password protected. Enter the password to view comments.”); ?>


    /* This variable is for alternating comment background */
    $oddcomment = ‘#e5e5e5’;

    <!– You can start editing here. –>
    <div id=”comments”>

    <?php if ($comments) : ?>
    <h3 ><?php comments_number(‘No Responses’, ‘One Response’, ‘% Responses’ );?> to “<?php the_title(); ?>”</h3>

    <?php $count=0; ?>
    <?php foreach ($comments as $comment) : ?>
    <?php $count++; ?>

    <div style=”padding: 5px; padding-bottom: 20px;”>

    $email = $comment->comment_author_email;
    $default = get_bloginfo(‘stylesheet_directory’) . “/default.gif”;
    $size = 40;
    $grav_url = “ gravatar_id=”.md5($email). “&default=”.urlencode($default). “&size=”.$size;
    <div class=”commentheader”>
    <?php echo “<div style=\”color: #000;padding-left: 10px;\”><div style=\”display:inline; font-weight: bold; font-family: ‘Century Gothic’, Verdana, sans-serif; font-size: 10pt;\”>$count</div>  “; ?>
    <?php echo “by “; comment_author_link(); ?> on
    ” title=””><?php the_time(‘l, F jS, Y’) ?>
    <?php edit_comment_link(‘e’,’|’,”); ?>
    <?php if ($comment->comment_approved == ‘0’) : ?>
    Your comment is awaiting moderation.
    <?php endif; ?>

    if (strstr($_SERVER[‘HTTP_USER_AGENT’], “MSIE”)) {$ie=TRUE;}

    <?php if (!$ie) { ?><img style=”margin-top: 12px; margin-right: 5px; float: left; border: 1px solid #fff;” src=”<?php echo $grav_url; ?>” alt=”” /><?php } ?><?php comment_text() ?>

    <div style=”clear: both;”></div>

    <?php endforeach; /* end for each comment */ ?>

    <?php else : // this is displayed if there are no comments so far ?>

    <?php if (‘open’ == $post-> comment_status) : ?>
    <!– If comments are open, but there are no comments. –>

    <?php else : // comments are closed ?>
    <!– If comments are closed. –>
    <p class=”nocomments”>Comments are closed.

    <?php endif; ?>
    <?php endif; ?>
    <?php if (‘open’ == $post-> comment_status) : ?>

    <h4><font color=”#000000″><u>Sign
    up to get your own gravatar
    <h4><font color=”#FFFFFF”><small>This entry was posted on
    <?php the_time(‘l, F jS, Y’) ?>
    <?php the_time() ?>
    . You can follow any responses to this entry through the
    <?php comments_rss_link(‘RSS 2.0’); ?>
    feed.<u> If you’re wondering how to get<font color=”#666699″> <font color=”#FFFF00″>your
    very own icon</font> <font color=”#FFFFFF”>next to your comment,
    go visit
    and get yourself signup</font></font></u></small> </font></h4>
      <div id=”commentbox”>

    <h3 id=”respond”>Leave a Reply</h3>

    <?php if ( get_option(‘comment_registration’) && !$user_ID ) : ?>
    You must be /wp-login.php?redirect_to=<?php the_permalink(); ?>”>logged in to post a comment.
    <?php else : ?>

    <form action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php” method=”post” id=”commentform”>

    <?php if ( $user_ID ) : ?>

    Logged in as /wp-admin/profile.php”><?php echo $user_identity; ?>. /wp-login.php?action=logout” title=”<?php _e(‘Log out of this account’) ?>”>Logout »

    <?php else : ?>

    <input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”22″ tabindex=”1″ />
    <label for=”author”><small>Name <?php if ($req) _e(‘(required)’); ?></small></label>

    <input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”22″ tabindex=”2″ />
    <label for=”email”><small>Mail (will not be published) <?php if ($req) _e(‘(required)’); ?></small></label>

    <input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”22″ tabindex=”3″ />
    <label for=”url”><small>Website</small></label>

    <?php endif; ?>
    <!–<small>XHTML: You can use these tags: <?php echo allowed_tags(); ?></small>–><div id=”commentbox”>
    <textarea name=”comment” id=”comment” cols=”65″ rows=”10″ tabindex=”4″></textarea>

    <input name=”submit” type=”submit” id=”submit” tabindex=”5″ value=”Say it!” />
    <input type=”hidden” name=”comment_post_ID” value=”<?php echo $id; ?>” />

    <?php do_action(‘comment_form’, $post->ID); ?>


    <?php endif; // If registration required and not logged in ?>
    <?php endif; // if you delete this the sky will fall on your head ?>


Viewing 5 replies - 1 through 5 (of 5 total)
  • any guru there………….. plz help me

    First, pasting entire templates/long bits of code into the forums is not a good idea. As you may notice, a lot of it is unreadable. A better option is to use a site like:

    I’d recommend pasting up your comments.php over there, then give the link provided for it in a reply.

    Second, what exactly are the errors you’re seeing?

    thanks. her’s the link




    jahangirafzal: what problem(s) are you experiencing? I see that you’re using the plugin in your comments.php already; and it looks like you want to replace that with my gravatars plugin.

    The foreach that starts the comment loop is on line 28 of your paste, immediately underneath $count = 0;.

    Underneath that is the plugin bit. You should replace that with the code from my plugin. Here is a complete comments.php from the Default (Kubrick) theme with gravatars integrated. Does that help?

    thanks for the help

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘gravatars-2.6 help’ is closed to new replies.