Last active
December 19, 2018 11:09
-
-
Save haroldparis/8a9728fa61a54600ad6b13b084677b22 to your computer and use it in GitHub Desktop.
Force Yoast SEO to only use Featured Image for og:image on singular
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 | |
// Tell WordPress SEO to use only full featured image for og:image output... and nothing else on singular | |
function only_full_og_featured_image() { | |
global $post; | |
if ( is_singular() ) { | |
if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail( $post->ID ) ) { | |
$featured_image_url = wp_get_attachment_image_src(get_post_thumbnail_ID( $post->ID ), 'full' ); | |
return $featured_image_url[0]; | |
} | |
} | |
} | |
add_filter('wpseo_opengraph_image','only_full_og_featured_image'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment