Search code examples
phpfacebookfacebook-likehref

Facebook Like for specific items instead of the main site


I installed a Facebook Like button in each of the items sold in a website. I was expecting that, when a user would click on Like item ABC, then his Facebook would post the link to such item and one of the item's pictures. However, it is just posting the main website's picture although the link refers to item ABC as expected.

How could I get the link to post the picture of the specific item that has been liked?

Here is the code:

<div class="fb-like-items">
    <div class="fb-like" data-href="http://www.AAAAAAA.es/store/itemsDescr.php?itemId=<?=$itemId?>" data-send="false" data-layout="button_count" data-width="100" data-show-faces="true" data-font="segoe ui"></div>
</div>

Solution

  • You need to ensure that each item's page has the proper meta-og tags, as specified by Facebook's Developer documentation (https://developers.facebook.com/docs/opengraph/using-objects/#creating).

    For example:

    • Each item should link to it's page (ABC should have it's own page).
    • On this page, you'll need to set the proper meta tags in the <header> tags.
    • The meta tags are as follows:

      <meta property="og:type" content="website" />

      <meta property="og:url" content="http://example.com/abc" />

      <meta property="og:title" content="ABC TITLE" />

      <meta property="og:image" content="http://www.example.com/image.jpg" />

    You can also utilize the Facebook Debugger to check for any errors in your meta tags - https://developers.facebook.com/tools/debug