• Resolved talgalili

    (@talgalili)


    Hello,

    I moved my site from http to https, but I wish to preserve my facebook likes. From what I read, I should use the og:url metatag so that facebook will know how to fix the likes on that page. I tried the following code, but it fails to change my urls from https to http in jetpack. Any suggestions?

    function https_to_http_url( $url ) {
        $url = str_replace('https://', 'http://', $url );
        return $url;
    }
    
    function jetpack_og_url_https_to_http( $tags ) {
        unset( $tags['og:url'] );
    
        $tags['og:url'] = https_to_http_url($tags['og:url']);
        return $tags;
    }
    add_filter( 'jetpack_open_graph_tags', 'jetpack_og_url_https_to_http' );

    https://wordpress.org/plugins/jetpack/

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

    (@jeherve)

    Jetpack Mechanic 🚀

    Since you unset $tags['og:url'], you can’t pass it later to your https_to_http_url() function.

    I’d recommend changing the protocol inside $tags['og:url'] before you actually unset it.

    I hope this helps.

    Thread Starter talgalili

    (@talgalili)

    Hi Jeremy,

    I erased the line with the unset code. But still I see my posts with og:url which includes https instead of http.
    What else could I be doing to make this work? (without it, moving from http to https will make all of my facebook likes disappear).

    Thanks,
    Tal

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Something like will work:

    function jeherve_og_http( $tags ) {
            $tags['og:url'] = str_replace( 'https://', 'http://', $tags['og:url'] );
    
            return $tags;
    }
    add_filter( 'jetpack_open_graph_tags', 'jeherve_og_http' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Force Jetpack to use og:url with http on an https website’ is closed to new replies.