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 28 replies, has 4 voices, and was last updated by  eric 2 weeks, 2 days ago.

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


    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?



    #26346 Reply

    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.

    #26375 Reply


    Thank you so much! That worked.

    #33898 Reply



    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


    #53585 Reply

    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.



    #64635 Reply


    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!


    #64657 Reply

    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 ;

    #64672 Reply


    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.

    #64689 Reply

    What code is on line 5?

    #64696 Reply


    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

    #64697 Reply

    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.

    #64705 Reply


    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!

    #64717 Reply

    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.

    #64800 Reply


    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!

    #64899 Reply

    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

    #64907 Reply


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

    #64908 Reply

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

    #65408 Reply


    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?


    #65554 Reply

    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.

    #70516 Reply


    I also used the code as instructed above however when put in funtion.php the site does not work.
    function rsssl_exclude_http_url ($ html) {
    // thay thế địa chỉ https vào http
    $ html = str_replace (‘data-href = “”,’ data-href = “” ‘, $ html); return $ html;
    add_filter (“rsssl_fixer_output”, “rsssl_exclude_http_url”);
    Anyway thank you very much

    #70683 Reply

    Mark Wolters

    Hi, there shouldn’t be a space between the & and html. They should be written together, like this:

    function rsssl_exclude_http_url ($html) {
    // thay thế địa chỉ https vào http
    $html = str_replace ('data-href = "",' data-href = "" ', $html); return $html;
    add_filter ("rsssl_fixer_output", "rsssl_exclude_http_url");

    that should make it work. Please also pay attention if the ” and ‘ qoutes are parsed correctly in your editor. That might cause it to fail as well.


    #74511 Reply


    This works only if Auto-replace mixed content are turned off, is it a way to make it work without turning it off (for the http part) ?

    global $post, $url ;
    $compare_date = strtotime( “2018-01-21″ );
    $post_date = strtotime( $post->post_date );

    $url = get_permalink();

    if ( $compare_date >= $post_date ) {

    //old post published with http
    $url = str_replace(‘https://’, ”, $url); ?>

    <div class=’fb-comments’ data-href=”http://<?php echo $url ?>” data-width=”715″ data-numposts=”5″></div> <?
    } else { ?>
    //new post published after https
    <div class=’fb-comments’ data-href=”<? echo get_permalink(); ?>” data-width=”715″ data-numposts=”5″></div>



    #74650 Reply

    Mark Wolters

    Hi Ephram,

    it sounds like the mixed content fixer is replacing the data-href to https:// as well. This is something that should be fixed by adding this code to your theme’s functions.php file (replacing with your own domain):

    function rsssl_exclude_http_url ($html) {
    $html = str_replace ('data-href = "",' data-href = "" ', $html); return $html;
    add_filter ("rsssl_fixer_output", "rsssl_exclude_http_url");

    Can you check if the code is present in your theme’s functions.php file?


    #98376 Reply


    Thanks for this invaluable bit of code.

    I’m having a problem with displaying comment counts post the SSL update though.

    Are there any solutions?

    Prior to moving to SSL, I could get comment counts from this: <fb:comments-count href=”<?php echo get_permalink($post->ID); ?>”></fb:comments-count>

    Sample page is here:

    Any insight would be great, I’m a total novice here.

    #98426 Reply

    Mark Wolters

    Hi Ian,

    since the site has moved to SSL the get_permalink function will likely return an https:// permalink. If the comments are made on http:// this can result in an incorrect count. However it does seem that the url used by the Facebook comments plugin is http://. I’d suggest to contact the developer of the comments plugin about this, perhaps they can provide you with more information about why this is happening.


    #148777 Reply


    Please tell me what file you add the code in.
    I really want to apply your method to the problem of facebook comments disappear.

    Thank you!

    #205649 Reply


    I have the same error

    #205669 Reply

    Mark Wolters

    Hi Dinhat,

    have you added the code to your functions.php file?

    #231191 Reply


    my site was ssl compliant. I wished to restore comments from the facebook comments plugin. Eventually I saw signs pointing to this plugin and some code being the solution. I’ve installed the plugin and activated it. I’ve tried adding all the codes to my functions.php that I’ve seen, nothing works. Specifically, the codes on this page come back with various errors in dreamweaver, and If I ignore the errors and upload, it breaks the site (easily fixed by deleting the code and replacing the file).

    I hope you can help me figure out what I’m missing. I’ve found another plugin that restores the facebook comments through it’s structure…but it’s settings do not match my theme, and there seems to be no way to deal with that…so I’m hopefully you can help me sort out how things are suppose to work over here.


Viewing 29 posts - 1 through 29 (of 29 total)
Reply To: Recovering Facebook comments for all links after moving to HTTPS
Your information: