1

I've added the Facebook comment plugin on a blogger blog and it's working fine except that it's treating the same url differently on desktop and mobile devices. In the code that I use, there's a expr:href='data:post.url' which helps to identify the current url of the page. The issue is, when a user is on the desktop browser, the link will be something like example.blogspot.com/post1.html but the same link on mobile device will look something like example.blogspot.com/post1.html?m=1 where m=1 is added to identify that the user is on a mobile browser. There comes the issue. Facebook comment plugin is treating the same page as different pages simply because there's a slight difference at the end of the page (m=1). Result is, mobile users can't see comments which are made from the desktop browser and vice versa. Comments will be visible if I manually add a m=1 in the desktop browser. Mobile version of the blog is turned off. How to fix this?

One related question though not same problem: Facebook comments plugin - same comments on every page

Community
  • 1
  • 1
Mattt
  • 73
  • 1
  • 1
  • 8

1 Answers1

1

Use

expr:href='data:post.canonicalUrl'

instead of

expr:href='data:post.url'

The benefit of using data:post.canonicalUrl is that the URL always remains the same whether you are using it on desktop or mobile. Also, it always returns the blogspot.com version of the URL (when you are not using a custom domain) remaining unaffected by the changing ccTLDs

Prayag Verma
  • 5,581
  • 3
  • 30
  • 56
  • Unfortunately it's not working. still I'm unable to see comments made from mobile device on desktop and vice versa. if ?m=1 is there,then all comments from mobile devices are visible. Thanks for the help btw. Forgot to mention, I'm using a custom domain – Mattt Feb 28 '17 at 08:14
  • This should work for the new posts that you create going forward. The comments for them would only link to the URL of the type `yourdomain.com/YYYY/MM/post-title.html` irrespective of the mobile or desktop version being opened. For the older posts, there is no way to migrate the comments which are linked to different URLs. As Facebook links comment to URLs, if you want to show comments linked to the mobile version or other versions (like when URL had ?m=0 ), you might have to show more than a single Facebook comment box for older posts, also refer to http://stackoverflow.com/q/17570850/933980 – Prayag Verma Feb 28 '17 at 09:16
  • 1
    Thanks a lot Prayag. It's working. I was using old code from some website and now I used the recent code from facebook developer page and like you said, used expr:href='data:post.canonicalUrl' instead of expr:href='data:post.url' and I can see it correctly. btw, i don't have older comments and it's not a problem. Just testing it on a spare blog before implementing on the main one. Once again, thanks. – Mattt Feb 28 '17 at 11:37