How can i display correct post thumbnail on facebook share?

  • Unknown's avatar

    Although there is a lot of articles about displaying right post thumbnail for Facebook sharing but I am having problem with it.

    There is thumbnail choosing option inside facebook share window.
    My requirement is that the featured image to be the first one displayed without the option to change it to any other image.
    Currently i am getting multiple images to choose when i share a
    post from the blog worldtruth.tv

    I tried a lot but could not solve it. I tried adding OG Tags manually to head. I added the following code before <?php wp_head(); ?>

    ————————————————————————————————-
    <?php
    global $wp_query;
    $thePostID = $wp_query->post->ID;
    if( has_post_thumbnail( $thePostID )){
    $thumb_id = get_post_thumbnail_id( $thePostID );
    $image = wp_get_attachment_image_src( $thumb_id );
    echo ‘<meta property=”og:image” content=”‘.$image[0].'” />’;
    } ?>
    ————————————————————————————————-

    Could you please tell me the code that I should put inside my head tags so that when I share through Facebook, there is no option for choosing a thumbnail but that it always shows a thumbnail of a post.

  • Unknown's avatar

    You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.

    If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.

    This is an automated message.

  • The topic ‘How can i display correct post thumbnail on facebook share?’ is closed to new replies.