CMS: Wordpress
FB Comment Plugin before migration: Facebook Comments
SSL Plugin: Really Simple SSL.

I have hundreds of pages and thousands comments via FB Comment plugin. After migrating to https/SSL, all share counts and comments are lost. Actually not lost, the comment is there, we just have to call them back.

I followed many tutorials from many blogs and from Really Simple SSL forum, but the tricky part is how to restore facebook comments. Many times I tried with different ways but did not succeed. Here, I post based my own experience that finally succeed for restoring facebook share counts and comments.

Restore Facebook Share Counts

Insert this code to functions.php:

function rsssl_exclude_http_url($html) {
//replace the https url back to http
$html = str_replace('property="og:url" content="https://www.domain.com','property="og:url" content="http://www.domain.com', $html);
$html = str_replace('data-href="https://www.domain.com', 'data-href="http://www.domain.com', $html); return $html;
}
add_filter("rsssl_fixer_output","rsssl_exclude_http_url");

Note: change all www.domain.com with your domain name. And, if before migrating to SSL you were using non-www, then delete www from the code.

This code will automatically restore your facebook share counts.

Restore Facebook Comments

Steps must to do:

  • Change old facebook comment with Fancy Facebook Comment Plugin. And activate it.

  • Insert this code to functions.php:

function heateor_ffc_custom_target_url( $post_url, $post ) {
    return str_replace( 'https://', 'http://', $post_url );
}
add_filter( 'heateor_ffc_facebook_comments_target_url', 'heateor_ffc_custom_target_url', 10, 2 );

Further discussion please fill in the comment section below.**