No gravatar when using Jetpack Comments
-
Hello, Thanks again for this beautiful plugin.
I am suing Jetpack Comments on blog on https://hydrablue.com
Blog post e.g. https://hydrablue.com/hidden-symptoms-of-chronic-dehydration
The issue is that the Gravatars are not showing, though they show up during the comment writing but not when posted.
-
Perhaps the code that is used to display the comments, usually in
comments.php
within your theme, doesn’t refer to the Gravatars at the moment. Older themes won’t have this as Gravatars weren’t yet part of WordPress comments. In thecomments.php
where you want to list comments you can add<?php wp_list_comments('type=comment&callback=comment_callback'); // replaces older code to use the Gravatar-supported comment display of WordPress 3.x+ ?>
and then infunctions.php
within your theme add the code to actually display a single comment (called once for every comment). The comment callback code my site uses, just to give you an example, is:// comment callback function that displays a comment in comments.php (we use this to allow stylizing the display) function comment_callback($comment, $args, $depth) { $GLOBALS['comment'] = $comment; extract($args, EXTR_SKIP); if ( 'div' == $args['style'] ) { $tag = 'div'; $add_below = 'comment'; } else { $tag = 'li'; $add_below = 'div-comment'; } ?> <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>"> <?php if ( 'div' != $args['style'] ) : ?> <div id="div-comment-<?php comment_ID() ?>" class="comment-body" style="border-style:dashed; border-width:1px; border-color: #FFBC73; margin-bottom:1px"> <?php endif; ?> <div class="comment-author vcard" style="padding-left:5px"> <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?> <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?> </div> <?php if ($comment->comment_approved == '0') : ?> <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?> <?php endif; ?> <div class="comment-meta commentmetadata" style="text-align:right; font-style:italic; padding-right:5px; padding-top:5px"> <?php /* translators: 1: date, 2: time */ printf( __('%1$s at %2$s'), get_comment_date('j F Y'), get_comment_time()); edit_comment_link(__('(Edit)'),' ','' ); ?> </div> <div style="padding-left:5px"> <?php comment_text() ?> </div> <div class="reply" style="padding-left:5px"> <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?> </div> <?php if ( 'div' != $args['style'] ) : ?> </div> <?php endif; ?> <?php } ?>
Hope this helps.
Thanks for the help, i tried to do the same but it is showing some error. Parse error: syntax error, unexpected ‘}’ in /home2/hydrablu/public_html/wp-content/themes/theme/functions.php on line 208
Below is the code my website is using.
comment.php
[Excessive code moderated. Please use a pastebin.]
“[Excessive code moderated. Please use a paste bin.]”, so I can’t see the code… I’ll try to help if you can paste the code somewhere…
But, actually you should only modify custom themes, so if you are using a WordPress-supllied theme then this fix shouldn’t be done as it will be undone when a theme update is made available.
So maybe see if the Avatar settings in the Discussion settings page are the culprit…
Okay. Here is the code.
comments.php: https://pastebin.com/VN7hJAX7
functions.php: https://pastebin.com/r5H7EsBjAnd yes, the Avatar display is mark checked.
Yes, but aren’t you using the TwentyTen theme? Because you really shouldn’t manually edit any themes that are not custom themes you develop. So I’d be hesitant to suggest you make any modifications to the theme as I originally suggested.
Yes, its a custom theme based on Twenty Ten. I appreciate your kind support.
Okay, so maybe it is good to show you the whole of my site’s (https://alex.clst.org/dbd)
comments.php
as an example of how that file should be put together:<?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">This post is password protected. Enter the password to view replies.</p> <?php return; } } ?> <!-- You can start editing here. --> <?php if ($comments) : ?> <br /><h3 id="comments"><?php comments_number('No Replies', 'One Reply', '% Replies' );?> to “<?php the_title(); ?>”</h3> <?php wp_list_comments('type=comment&callback=comment_callback'); // replaces older code to use the Gravatar-supported comment display of WordPress 3.x+ ?> <?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">Replies are closed.</p> <?php endif; ?> <?php endif; ?> <div class="noprint"> <?php if ('open' == $post->comment_status) : ?> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a reply.</p> <?php else : ?> </br> <?php comment_form(); // Replaces old <form> block to support Jetpack comment form ?> <?php endif; // If registration required and not logged in ?> <?php endif; // if you delete this the sky will fall on your head ?> </div>
My theme is likewise based on TwentyTen. The code I put in an earlier post here of mine should go just in the
functions.php
. You can modify thestyle
attributes of parts of the comment_callback to your liking. See if this works, it will be faster than me reading your site’s code, and as both are based on TwentyTen nothing terrible should come of you pasting wholesale my site’s code.I did the same. Showing the error again: Parse error: syntax error, unexpected ‘}’ in /home2/hydrablu/public_html/wp-content/themes/theme/functions.php on line 205
May be i am pasting the code wrong in functions.php
I think around line 205 is code that you didn’t just paste in, or at least based on the old pastebin that is the case. As you should know if you are maintaining a custom theme, the
}
characters are ending if statements, loops, or functions, so perhaps all you need to do is delete one of them from line 205?Make sure the code you paste is not between existing functions, perhaps by putting it just below the
<?php
line. This may fix your issue as well.I tried removing the } its leading to some header information missing errors.
So try my suggestion just above, revert to your working
functions.php
and then paste the code from my first post here just below the<?php
line. This is seemingly more complicated than it should be to get this to work…
- The topic ‘No gravatar when using Jetpack Comments’ is closed to new replies.