Search code examples
wordpressfacebookfacebook-opengraphfacebook-comments

FB Comment 'Also Post on Facebook' and FB Share - Linkback to different URLs?


This is SO annoying.

The Issue is a matter of two scenarios behaving differently when I expect (and wish) them to be the same, these relate to the same webpage/article which features both Facebook Comment widget and a Share icon.

It's important to mention that the webpage is a Wordpress article, and we redirect:

  • from www.example.com/wordpress/articles/news/thearticle
  • to www.example.com/news/thearticle

The issue explained:

Scenario 1) I visit the article and type a facebook comment, I also click 'Also Post on Facebook'. When I view may facebook wall and see the share with the comment I just made, the link is linking back to the wordpress URL - I do not want this.

Scenario 2) I visit the article and share it through the Share icon. On my wall this time the linkback URL is the short one - this is good.

Important info regarding debugging

My OG URL tag is correct:

<meta property="og:url" content="http://www.example.com/news/thearticle"/>
  • Facebook debugger is picking up the correct desired URL as above, also listing the desired Fetched URL and Canonical URL. All seems to be what I want it to be.
  • This is true regardless of whether or not I scrape the URL before or after I try this procedure.
  • Even if I then go back and do another comment with 'also post on FB' after doing a scrape with FB debugger, still the share links to the wrong/long format/original URL.
  • However, if I at any point share via the share icon, not the comment-share, the desired URL is present as per the OG URL.
  • If I do a comment-share, then an icon-share, then another comment-share, the comment share ones still have the wrong URL even though the icon-share had the correct one!

Any ideas? Thanks so much in advance to anyone who can help :)


Solution

  • It seems that the Comments FB plugin doesn't get the page info from OpenGraph, but expect a data-href attribute, or if not provided will use the current url by default.

    From the doc:

    data-href

    Description : The absolute URL that comments posted in the plugin will be permanently associated with. Stories on Facebook about comments posted in the plugin will link to this URL.

    Default : Current URL.

    So what you need to do is to provide the valid URL as an HTML5 attribute on your plugin wrapper:

    <div class="fb-comments" data-href="http://www.example.com/news/thearticle" data-numposts="5"></div>