Yoast SEO plugin open graph add meta tag to fetch Avatar from Author Page
I'm trying to create a new og:image for author avatar when the users sharing their author profile page to Facebook.
I'm a newbie with WordPress, After searching for more than 6 months but i'm always failing.
My site is multi-authors and all what i need to add og:image meta tag for author.php "author profile", I'm stuck and I really get tired from searching.
When our users trying to share his profile..the avatar image not coming up! because Facebook can't find the author avatar og:image!
Plugins i'm using : Yoast SEO, Simple Local Avatars, AddToAny Share Buttons.
I tried to use wpseo_opengraph_image filter, but not working.
This is code I'm using:
function custom_author_og_image() {
if ( is_author ( ) ) {
$author = get_queried_object();
$image_attributes = get_avatar_url( $author-user_email, 'full' );
if ( $image_attributes !== false ) {
return $image_attributes[0];
}
}
}
add_filter('wpseo_opengraph_image', 'custom_author_og_image', 10, 0);
Topic avatar author open-graph Wordpress
Category Web