Facebook comments on a website are more hassle than they’re worth

I recently switched my domain from danny.gb.net to danny.gg – all was well and good, until I realised my comments were missing.

After some extensive Google-fu, I couldn’t find any proper solutions on migrating a domain and keeping all comments intact.  So I had to hack the Facebook plugin a little.

I’ve always used this plugin to enable Facebook comments.  Seemed like a great idea at the time.  If you’ve switched domain and encountered a similar issue, you’ll find that the problem is caused by having a data-href attribute on the comments box.  This basically means that Facebook uses your URL as a “unique ID” of sorts, so it knows which comments belong to which page.

Logically, you’d think it’d just be the request URI (the bit after the domain), maybe with a setting in the app itself on the developer console.  Nope.

The easiest fix, which is quick and dirty, is to edit the Facebook plugin directly and add the following bit of code:

[php]global $post;
if(strtotime($post->post_date) < 1435708800) { /* replace this number with your Unix timestamp (explained below) */
$options[‘href’] = str_replace(“danny.gg”, “danny.gb.net”, $options[‘href’]); /* replace “danny.gg” with “newdomain.com” and “danny.gb.net” with “olddomain.com” */

Of course, you’d need to tweak this a bit specifically for your website.  I used the Unix Timestamp Converter to calculate a timestamp somewhere between the last post on my old domain and the first one on my new domain (in my case, the first of July 2015)

What this basically does is replace the new domain with the old one for any posts published prior to the domain switchover.  Of course, if you’ve had comments since switching your domain, you’ll have to decide whether to use the old comments or the new – there’s unfortunately no way of merging them.

I think I’ll be finding a way to export comments and going back to standard WordPress.

Leave a Comment