WordPress.org

Ready to get started?Download WordPress

Forums

SEO Facebook Comment
Feature Request - og:image Support (7 posts)

  1. Sam
    Member
    Posted 1 year ago #

    I edited the plugin to include this, but it would be great if it had it by default. Here's the code I used:

    if (has_post_thumbnail()) {
                  $post_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');
                  $imageUrl = $post_thumbnail[0];
                }

    Obviously that's pretty simple and only uses post thumbnails, so there's no support for a default image or images inserted into posts, but it works for what I need.

    og:description support might be good too to correct the warnings here: http://developers.facebook.com/tools/debug/.

    http://wordpress.org/extend/plugins/seo-facebook-comments/

  2. benny_ray
    Member
    Posted 1 year ago #

    Dear Sam,

    Could you please help me?

    I would like to have a default Image as comment image on FB.

    What would be the code and where should i put in?

    Thank you in advance!

  3. Sam
    Member
    Posted 1 year ago #

    In the plugin's root directory there is a file called seofacebook.php which you'll need to edit. Insert the following around line 321:

    if (has_post_thumbnail()) {
                  $post_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');
                  $imageUrl = $post_thumbnail[0];
                } else {
                	$imageUrl = "http://path.to/default/image.jpg";
                }

    Of course you can eliminate the if statement if you don't want to use featured images when they are available. The other thing you need to do is output the tag, which you can do by adding this code around line 352:

    "<meta property='og:image' content='{$imageUrl}' />",
  4. benny_ray
    Member
    Posted 1 year ago #

    Hi Sam!

    Thanks for the promt reply.

    I had time to try your solution, but unfortunately it didn't work. I've faced with the issue as before and now I can not see even the comment on FB.

    You can find the seofacebook.php file with the added lines suggested by you on the link. Could you please take a look on it what could be wrong?

    https://www.dropbox.com/sh/ve1e4qct2dvpwg6/88r6m39ymp

    Thank you for the help in advance!

  5. Sam
    Member
    Posted 1 year ago #

    I don't see any problems in the code, but your website doesn't seem to be using Open Graph tags. You may just need to turn them on in the plugin's settings. You can use the "debug" link above to see whether FB is seeing them for your pages or not.

  6. whyme26
    Member
    Posted 1 year ago #

    PERFECT!
    Thank you :)

  7. bigian5000
    Member
    Posted 10 months ago #

    Hi, could you be more specific about where this code goes in the seofacebook.php file. I can't see anywhere that tells me the line numbers. Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic