Recovering Facebook comments for all links after moving to HTTPS

Home Forums General issues Recovering Facebook comments for all links after moving to HTTPS

This topic contains 18 replies, has 3 voices, and was last updated by  Rogier Lankhorst 1 week, 4 days ago.

Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
  • #26345


    Hey Rogier,

    After moving my entire site to HTTPS (and using the RSSSL mixed content option), my Facebook comments disappeared. I have Facebook comments appear on multiple pages.

    I’m using this code right now:

    function rsssl_exclude_http_url($html) {
    //replace the https url back to http
    $html = str_replace(‘data-href=””‘, ‘data-href=””‘, $html); return $html;

    And it’s working specifically for to

    But I also need to do that for to

    How can I adjust the code above so I can make that happen?




    If you remove the closing quotes, like this:

    function rsssl_exclude_http_url($html) {
    //replace the https url back to http
    $html = str_replace(‘data-href=”‘, ‘data-href=”‘, $html); return $html;

    It should work. When the quotes are gone, it will replace back any string with that domain. In the former version it would replace all strings ending with a quote.



    Thank you so much! That worked.




    Thank you for a great plug-in! I’m experiencing the same problem (disappearing FB comments) and I’m exited that I found this solution here but… Where do I place this code? I would love a detailed explanation if possible as I’m not so skilled with code 🙂

    Many thanks



    Sunday Ukafia


    Add the code to your theme’s function.php file (You can add it at the end)

    Navigate to appearance – editor – functions.php (located at the right hand side)

    Note that the code will be removed if you update your theme.

    It is recommended to create a child theme and add it to your child theme function.php

    Google how to create a WordPress Child theme for help. Its actually quite simple.





    I’ve tried the solution posted above (added the code to the functions.php). but I am getting the following error: Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /wp-content/themes/Fonovit/functions.php on line 1093. Any ideas why it does not work in my case? (

    Thanks a lot for any advice!



    This might happen if there’s a PHP error on the line before. For example, if the last line before the function did not end with ;



    Thank you for the reply. It have been the case, so I have added ; to the previous function(seems like it was missing there), but I still get an error Parse error: syntax error, unexpected ‘=’ in /wp-content/themes/Fonovit/functions.php on line 1095, if I place it in the front (just after <?php) of functions.php I also get: Parse error: syntax error, unexpected ‘=’ in /wp-content/themes/Fonovit/functions.php on line 5

    A bit lost here. No clue what is causing it.


    What code is on line 5?



    The same. I’ve tried to paste it to the beginning of the document and to the end (not at the same time), just to be sure it is not some strange character that got into functions.php accidentally. When I paste it to the document the website stops working. When I remove it all works fine


    What I mean is, the error says there’s a fatal error on line 5. To say anything about it, I need to know what code you have on line 5.

    Possibly the quotes are changed by copying them. In that case you can try retyping the quotes in the code. If you post the line of code that is causing the error I might be able to help.



    Seems like the quotes were the problem. At least the website is working fine.
    That the code I have now.

    function rsssl_exclude_http_url($html) {
    //replace the https url back to http
    $html = str_replace(‘data-href=”’, ‘data-href=”’, $html); return $html;

    But I still do not see the comments

    Could it be the way the facebook comments are implemented (as a code snippet inside of the theme)

    <div class=”facebook-comments”>
    <div class=”fb-comments” data-href=”<?php echo get_permalink( $post->ID ); ?>” data-width=”576″ data-numposts=”15″></div>

    Thank you so much!


    You can also try to change the og:url back to http:
    $html = str_replace(‘og:url=”https://’, ‘og:url=”http://’, $html);

    If that doesn’t help, you need to check how Facebook returns the shares. I have a very simple script to test this:
    Where you can compare the shares that Facebook returns for the (recovered) share button, and the shares that are returned using the API. If you enter the http url, and the button does not show the correct number of shares, you can only recover the shares by using the API, and not using this replace script.

    You need to enter the url with http to see the correct results.



    Thank you for your help. It seems that I need to use the API (still have to figure out how to do it :)) and the script does not work in my case. Thank you for your help!


    In case you don’t want to do this yourself: the social add-on for Really Simple SSL has also built in share buttons, which use the API. You can customize the buttons using a template and css



    Would that plugin recover comments that disappeared after moving to SSL? That is what I need the most.


    No, I’m sorry, the API is used for shares only.



    Tried different options (seemed quite straightforward) (also paid plugin Lost on what could be the problem. Do you provide premium support service or maybe you could recommend someone who could have a look at my website and see what the problem is?



    We’d have to investigate the plugin to see how it is retrieving the comments, and if there is a hook that can be used to override the URL. If you contact us and send us a zipped file of your comments plugin, we can take a look.

Viewing 19 posts - 1 through 19 (of 19 total)

You must be logged in to reply to this topic.