alexdbd
Forum Replies Created
-
So maybe see if the Avatar settings in the Discussion settings page are the culprit…
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.
“[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…
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.
One way to post the screenshot is to simply upload it to somewhere in your WordPress site and paste a link into a reply here.
But here is something else to try and see if it fixes your problem (it fixed a similar problem that I had):
Open up the
functions.php
file in your theme’s directory using an (S)FTP client to access the web server ([WP-HOME]/wp-content/themes/THEME-NAME), or create it if it doesn’t yet exist (in this case be sure to add<?php
at the top of the file and?>
at the bottom of the file), and add the following:// remove autogenerated facebook open graph metadata remove_action('wp_head','jetpack_og_tags'); // manually add facebook open graph metadata function insert_fb_in_head() { global $post; if ( !is_singular()) //if it is not a post or a page return; //simply don't add og metadata to the header echo '<meta property="og:title" content="' . get_the_title() . '"/>'; echo '<meta property="og:type" content="article"/>'; echo '<meta property="og:url" content="' . get_permalink() . '"/>'; echo '<meta property="og:site_name" content="' . get_bloginfo('name') . '"/>'; if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image echo '<meta property="og:image" content="[URL TO DEFAULT IMAGE FOR POSTS]"/>'; } else { // the post has a featured image so go and use it $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' ); echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>'; } } add_action( 'wp_head', 'insert_fb_in_head', 5 );
Where I put “[URL TO DEFAULT IMAGE FOR POSTS]” replace that with the URL to a 100×100 pixel png file you upload to your web server that will be used if the post contains no image. If the post has an image this code will instead use it.
What this tells your site to do is disable Jetpack’s automated addition of Facebook metadata to posts and replaces it with your own implementation, which uses the image found in any post that contains an image but otherwise uses an image you explicitly choose in the block of code itself. I found that this stopped me from having Jetpack’s publicize use some random picture that wasn’t even real and instead now uses my site’s favicon (in a larger format).
Hope this helps.
Unfortunately a site URL is nearly useless when only filesystem-level access provides the ability to see the PHP code. What is
blog.php
, there should usually be no such file in a WordPress theme. The first two blocks of code I put above go intofunctions.php
directly (not within any functions currently in the file).You don’t put that second block of code straight into the
index.php
, you just put the line that refers to thepost-loop.php
in alone, something like this:<?php if (have_posts()) : // loop to get posts from the database and display them get_template_part( 'post-loop' ); ?>
Remember that the contents currently between that if loop have been cut out and are the only contents of the
post-loop.php
file you just created. You don’t have to do this last step, but doing it means you only have one place where the code to render posts resides which helps in later changes and debugging you may deal with.I’ve been describing the way it is set up, and working, on my blog (https://alex.clst.org/dbd), so the code I’ve shared with you does work when implemented properly. Perhaps the div your posts render in isn’t
content
, that may also screw things up. Look using theview source
or similar command in your browser to see what div the posts are thrown into and add that div name to thecontainer
value of the first code block above.Give us a screenshot of the Facebook post not a link to your profile as we aren’t friends with you. Then we can help debug the problem.
Yes, the theme must be modified to support Jetpack Infinite Scroll. Here is the minimum that must be done:
1. Add the following to
functions.php
in your theme directory:// theme support for Jetpack infinite scroll add_theme_support( 'infinite-scroll', array( 'container' => 'content', 'render' => 'infinite_scroll_render', 'footer' => 'footer' ) );
In “container” you put the div name that the main content of your site renders into, this is usually “content” but may be something different.
// render function for Jetpack infinite scroll that 2010 uses, the later WP themes don't need this function infinite_scroll_render() { get_template_part( 'post-loop' ); }
2. Put the code that renders a single post on the main page of your site (from
index.php
) into apost-loop.php
file. The first line should be something like<?php while (have_posts()) : the_post(); ?>
and the last line something like<?php endwhile; ?>
.
3. Optional, but delete that code that renders a single post inindex.php
and refer topost-loop.php
instead.That should do it.
I’ve just worked around any failings of Jetpack’s Facebook Open Graph metadata by manually replacing Jetpack’s auto generated
og
tags with ones I included in the theme itself (as my site uses a custom theme I maintain this works well, but I realize some of you may not be as lucky to have access to modifying the theme/knowing PHP). Here is what I did in step-by-step instructions:1. Add
remove_action('wp_head','jetpack_og_tags');
to your theme’sfunctions.php
file to disable Jetpack from generating the header metadata that is coming up with the wrong image. This plugin may work, but I always prefer to manage the code myself if at all possible: https://github.com/sgthemes/Remove-Jetpack-Open-Graph-Tags
2. I followed the code method of this page, but the plugin may work just as well: https://www.wpbeginner.com/wp-themes/how-to-add-facebook-open-graph-meta-data-in-wordpress-themes/
3. If you use the code method and don’t really want any default image then make a blank/transparent 100×100 px png to use. I used a version of my site’s favicon, but you can easily upload your Gravatar manually to use too.I’m having a similar problem on my blog https://alex.clst.org/dbd, but it has been happening ever since I started using Jetpack in early February. What gets displayed as the image appears to be a activity indicator, I have not the slightest clue where it is even getting that unless perhaps it is what the Gravatar system is returning when the avatar lookup possibly hangs or something (see indicator for hovercard loading to notice where I’m getting that hypothesis). A screenshot showing this is at https://alex.clst.org/machelp/fbjetpackpub.jpg. I think a good way to bypass this problem would be for an update to Jetpack to bring us a choice of which image source to prioritize first from that list Richard has from a month ago. That way we can all just force it to Gravatar avatars, or even a custom image we provide in the Publicize settings.
I see the exact same thing happening. Though the default text works in the wording of the rest of my sites, it would be very handy to have that working. The 2.2.5 update does not fix this, so I hope 2.2.6 comes out soon to fix this problem.