Yoast WP SEO - change the og:url to the current post url when using canonical url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// yoast wp seo plugin og:url override | |
// --------------------------- | |
// change the og:url to the current post url when using canonical url | |
// fix for share on instagram and Facebook to use the website url | |
// not the canonical url | |
// --------------------------- | |
add_filter( 'wpseo_opengraph_url', 'hhdev_change_opengraph_url' ); | |
function hhdev_change_opengraph_url( $url ) { | |
global $post; | |
return get_permalink($post->ID); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment