• Resolved agathongroup

    (@agathongroup)


    Greetings,

    I’m trying to write a dumb little filter to replace the og:url parameter with the https:// version of the page (in order to preserve share counts). However, despite the fact that the function *is* firing, as evidenced with error_log() calls showing up in the PHP log, the URL never gets replaced.

    The code in functions.php is straightforward enough:

    function my_opengraph_og_url( $url ) {
      return str_replace( 'https://', 'https://', $url );
    }
    add_filter( 'wpseo_opengraph_url', 'my_opengraph_og_url' );

    Running WP 4.9.8 and Yoast 8.3. Any ideas what I’m doing wrong?

    Thanks,
    Peter

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter agathongroup

    (@agathongroup)

    User error: an SSL mixed content filter was to blame. Sorry for the noise.

    I have the same problem, Can you tell me kindly how did you solve it?
    I wrote this script but it does not work

    <?php
    function my_opengraph_url( $url ) {
    global $post;
    $output = $url;
    if ($post->ID != 2268) {
    $output = str_replace( 'https://', 'https://', $url );
    }
    return $output;
    }add_filter( 'wpseo_opengraph_url', 'my_opengraph_url' );
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cannot replace og:url with wpseo_opengraph_url filter’ is closed to new replies.