Support » Plugin: Really Simple SSL » Recover share count after https

  • Resolved Coach Afrane

    (@coach-afrane)


    I lost all share counts after changing from http to https.

    Whiles searching for a solution I came across this thread.
    https://wordpress.org/support/topic/social-shares-count-recover-after-moving-to-https/

    I copied a code snippet and edited to my domain as directed

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

    It worked ok by restoring previous share counts. However, I realized share counts for post after https is now reversing back to zero.

    How can I get share counts for both before and after https combined or added together ie. for both http and https?

    Thank you.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author RogierLankhorst

    (@rogierlankhorst)

    Hi @coach-afrane,

    I have written an article on this, where I’ve also covered a method to used the post date to distinguish the http and https posts (scroll down to the bottom):
    https://really-simple-ssl.com/knowledge-base/how-to-recover-facebook-likes-after-moving-to-httpsssl/

    And some plugin solutions as well.

    Coach Afrane

    (@coach-afrane)

    Thanks for your reply, Rogier.

    I have gone through your article and it’s very helpful.

    I tried putting the code together so I can get for both before and after https.
    This what I ended up with. I don’t know coding but I got this;

    function rsssl_recover_shares($html) {
        //replace the https url back to http
        $html = str_replace('property="og:url" content="https://agrihomegh.com','property="og:url" content="http://agrihomegh.com', $html);
        $html = str_replace('data-href="https://agrihomegh.com', 'data-href="http://agrihomegh.com', $html); 
        return $html; 
    }
    add_filter("rsssl_fixer_output","rsssl_recover_shares");
    
    $start_date = '2019-03-01';
    $publish_date = get_post_time('U', false, $post->ID);
    
    if ($start_date && ($publish_date > $start_date)) {
    //use https shares
    } else{
    //use http shares
    }

    Am I right?
    Nothing is happening though.

    Plugin Contributor Mark

    (@markwolters)

    Hi,

    I don’t see the og:url propery in your page source, if it’s not there the code cannot replace it. You can add the og:url manually or by using an Open Graph plugin to see if that does retrieve the sharecount.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Recover share count after https’ is closed to new replies.