WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
No gravatar when using Jetpack Comments (22 posts)

  1. Yogesh Singh
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/jetpack/

  2. alexdbd
    Member
    Posted 1 year ago #

    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 the comments.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 in functions.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.

  3. Yogesh Singh
    Member
    Posted 1 year ago #

    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.]

  4. alexdbd
    Member
    Posted 1 year ago #

    "[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...

  5. alexdbd
    Member
    Posted 1 year ago #

    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.

  6. alexdbd
    Member
    Posted 1 year ago #

    So maybe see if the Avatar settings in the Discussion settings page are the culprit...

  7. Yogesh Singh
    Member
    Posted 1 year ago #

    Okay. Here is the code.

    comments.php: http://pastebin.com/VN7hJAX7
    functions.php: http://pastebin.com/r5H7EsBj

  8. Yogesh Singh
    Member
    Posted 1 year ago #

    And yes, the Avatar display is mark checked.

  9. alexdbd
    Member
    Posted 1 year ago #

    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.

  10. Yogesh Singh
    Member
    Posted 1 year ago #

    Yes, its a custom theme based on Twenty Ten. I appreciate your kind support.

  11. alexdbd
    Member
    Posted 1 year ago #

    Okay, so maybe it is good to show you the whole of my site's (http://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 the style 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.

  12. Yogesh Singh
    Member
    Posted 1 year ago #

    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

  13. alexdbd
    Member
    Posted 1 year ago #

    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?

  14. alexdbd
    Member
    Posted 1 year ago #

    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.

  15. Yogesh Singh
    Member
    Posted 1 year ago #

    I tried removing the } its leading to some header information missing errors.

  16. alexdbd
    Member
    Posted 1 year ago #

    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...

  17. alexdbd
    Member
    Posted 1 year ago #

    See if pasting this code works for functions.php: http://pastebin.com/QRdVGT3W. This combines your pastebin contents of the file with my function.

  18. Yogesh Singh
    Member
    Posted 1 year ago #

    I tried http://pastebin.com/QRdVGT3W Its working with no error but not making any changes on the comments as required.

  19. alexdbd
    Member
    Posted 1 year ago #

    Hmm. I'm at a loss for further ideas, then… There may be some other system (or plugin) that overwrites the theme support that is hiding the Gravatars, but I don't know what that would be. You could test with another theme and if the Gravatars don't show up there then it isn't theme code that is the problem. If they do show up then you at least know the theme code is blocking Gravatars, but after all you just tried with my suggestions I don't know what would be blocking it. Sorry I can't be of more help.

  20. Yogesh Singh
    Member
    Posted 1 year ago #

    Hey thats much more than what i expected. Thanks a lot Alex. Cheers to you!

  21. Yogesh Singh
    Member
    Posted 1 year ago #

    Just thought i should update it here. It got solved by installing a plugin 'Easy Gravatars' for now.

  22. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Hi there,

    The gravatar issue is usually because the account that is logged in to WordPress.com does not have a gravatar, or something if the sort. if you'd like me to look into it further, please let me know.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic