-
Hi,
I want to Prioritize Product gallery image as the og:image instead of featured image.
I am able to do it on SEO Press now with these code:// OG THUMBNAIL FB 2ND image
function sp_social_og_thumb($html) {
if (is_singular( 'product')) {global $product;
$attachment_ids = $product->get_gallery_image_ids();
if (!empty($attachment_ids)) {
$html = null;
foreach( $attachment_ids as $attachment_id ) {
$html .= '<meta property="og:image" content="'.wp_get_attachment_url($attachment_id).'" />';
$html .= '<meta name="thumbnail" content="'.wp_get_attachment_url($attachment_id).'" />';
$html .= "\n";
}
}
}
return $html;
}
add_filter('seopress_social_og_thumb', 'sp_social_og_thumb');Is it possible to do it with rankmath?
The ticket ‘Prioritize Product gallery image as the og:image instead of featured image’ is closed to new replies.