Search code examples
facebookfacebook-javascript-sdkfacebook-comments

Facebook Comments Plug-in posts an incorrect image and page text


We are using the Facebook comments plug-in on our pages using:

<div class="fb-comments" data-href="<?=$page_url?>" data-num-posts="2" data-width="520"></div>

...where $page_url contains the URL of that specific page (dynamically generated, think of it as article pages). However, when posted on Facebook Wall, the image and page content are different (shows a different page). When we click the link though, it does go back to the correct page.

Why does it get an image and page content from another page even though we have a unique ID on the URL?


Solution

  • I figured out how. I just need to put the necessary open graph metadata on top like so:

    <meta property="og:description" content="[page description]" />
    <meta property="og:image" content="[page image]" />
    

    This way, it always shares the correct image and description for that page.

    (For more info on open graph: http://ogp.me/)